Deleting a file using JavaScript gives an error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ckb
    New Member
    • Sep 2007
    • 17

    #1

    Deleting a file using JavaScript gives an error

    HI,
    I have created an excel application using the
    filesys = new ActiveXObject(" Scripting.FileS ystemObject");
    etc .
    code but now i want to delete the file because the sheet does not have any data.
    Eveythig works fine but it does not delete the file and gives me an error
    permission denied even though the folder has all the access.
    My code is
    filesys = new ActiveXObject(" Scripting.FileS ystemObject");
    if(OSheet.Range ("A10").Valu e = " ")
    {
    alert("Sheet is blank");
    oExcel.Quit();
    OSheet = null;
    oExcel = null;
    if(filesys.File Exists(SaveAsSt ring))
    {
    filesys.DeleteF ile(SaveAsStrin g);

    }
    }
    Can anybody help me with this.
    Thankyou
  • pronerd
    Recognized Expert Contributor
    • Nov 2006
    • 392

    #2
    Originally posted by ckb
    but now i want to delete the file
    This is an extreamly unsafe operation. IE is the only browser that will let you even try it, and Microsoft has had to add a lot of restrictions.

    You will need to go to the security tab, in the Internet Options icon in the control panel and set your security to the lowest setting. You should not access public internet sites while the browser is set to this mode. If you have Vista, or IE7 you will probably have to select the customized option and go though the active X options setting them all to enabled.

    Comment

    Working...