ASP Upload Delete is not working

Posted on 2006-05-16
Last Modified: 2006-11-18
I am uploading a file using ASP and i am trying to delete that file but that is not happening

i have used this code

Sub DeleteFromDisk1(sPath1)
      Dim oFS1, oFile1
      Dim nIndex1
      If sPath1 = "" Then Exit Sub
      Set oFS1 = Server.CreateObject("Scripting.FileSystemObject")
      If Not oFS1.FolderExists(sPath1) Then Exit Sub
      Set oFile1 = oFS.GetFile(sPath1 & "\Addition1.xls")
End Sub
Question by:ynaina
    1 Comment
    LVL 5

    Accepted Solution


    Try this...

    Sub DeleteFile(Path,File)
    Dim Fs
          Set Fs = Server.CreateObject("Scripting.FileSystemObject")
          'Checks that the file exists
          if Fs.FileExists(Path & "/" & File) Then
                'Deletes the file
                Fs.DeleteFile(Path & "/" & File)
          end if

    'Destroys open objects      
    Set Fs = Nothing

    End Sub

    DeleteFile Server.MapPath("FOLDER FILE IS IN),"NAME OF FILE"

    That should work okay


    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
    I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now