Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

delete file in asp

Options
  • 01-02-2008 8:17am
    #1
    Closed Accounts Posts: 1


    hi,

    i m new to asp ,plz help me, how do delete the this file "todayspecial.xml" . It works locally fine. when i upload the server not
    deleted "todayspecial.xml" file.

    <%
    dim fs,f,s
    set fs=Server.CreateObject("Scripting.FileSystemObject")
    set f=fs.GetFile(server.MapPath("updateXml\todayspecial.xml"))
    f.Delete(true)
    set f=nothing
    set fs=nothing
    set s=nothing
    %>


Comments

  • Closed Accounts Posts: 36,634 ✭✭✭✭Ruu_Old


    Moved from Newbies & FAQ.


  • Closed Accounts Posts: 1,200 ✭✭✭louie




  • Users Awaiting Email Confirmation Posts: 351 ✭✭ron_darrell


    Don't think the problem is with the ASP code - there's a big difference between a local served file and a web served file. A local served file will use the client permissions on the network (so if you would normally have permission to delete the file it will be deleted). On the web you only have such permissions as are given to the annonymous login account. So you'll need to give the user persmission to delete file (generally by adding the user account to the security of the folder and giving them read and write access to it).

    Hope that helps a little
    -RD


  • Closed Accounts Posts: 50 ✭✭shortcorner


    fileUpload.SaveAs(Server.MapPath("~/temp/") & fileUpload.FileName)
    Dim strfilename As String = Path.GetFileName(fileUpload.PostedFile.FileName)
    File.Delete(Server.MapPath("~/temp/") & strfilename)
    

    Hi there,

    I have a web form where people upload an attachment and send to me after it has been sent then it deletes it.
    You also may need to change permissions where you are allowing the file to be deleted. Your hosting company will have to do that for you.


  • Registered Users Posts: 721 ✭✭✭stakey


    Considering you're using MapPath you'll need permissions to be able to read above your account in a shared hosting environment, this allows your script to find the path to the file that it's trying to delete.

    These permissions are usually restricted by default but most hosting companies should allow you to this as ALOT of scripts are based around using MapPath, you'll need to contact your hosting provider and request they set you up with enough privileges to use MapPath.

    Failing that you probably need additional permissions for the NETWORK SERVICE account on the server you're on, you'll probably need 'Delete' permissions, but more than likely it's the above.

    All of this can be sorted by your hosting provider if they're familiar with the needs of ASP scripts.


  • Advertisement
Advertisement