?
Solved

ASP Upload Delete is not working

Posted on 2006-05-16
2
Medium Priority
?
260 Views
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")
      oFile1.Delete
End Sub
0
Comment
Question by:ynaina
1 Comment
 
LVL 5

Accepted Solution

by:
shaggy_the_sheep earned 150 total points
ID: 16689633
Hi

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

Richard
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Loops Section Overview
Suggested Courses
Course of the Month16 days, 21 hours left to enroll

862 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