Solved

Delete a file before uploading files

Posted on 2004-07-30
5
455 Views
Last Modified: 2008-01-09
My ISP has provided me with some code to upload files. Which works the first time. The second time I try to upload files it get the following error..

ABCUpload4.XField.4 error '80040050'

A Windows error - The file exists. - (0x00000050) occurred.

/partnersite/regions/EMEA/upload_success.asp, line 24


I talked to my ISP and they say the permissions are set properly. The only thing I've been able to deduce is that the myupload.dat file doesn't like to be overwritten.  How do I delete the file automatically before uploading my other files? Here is the code of the processing asp.

<%
Set theForm = Server.CreateObject("ABCUpload4.XForm")
theForm("filefield")(1).Save "myupload.dat"
%>


Thanks
0
Comment
Question by:kevinbenedict
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 3

Expert Comment

by:dwaldner
ID: 11677217
<%
set fso = Server.CreateObject("Scripting.FileSystemObject")
if fso.FileExists(FILEPATH) then
          Set file = fso.GetFile(FILEPATH)
          if fso.FileExists(BACKUP_FILEPATH) then
            Set file2 = fso.GetFile(BACKUP_FILEPATH)
            file2.Delete True
            Set file2 = nothing
          End if
          file.Move BACKUP_FILEPATH
          set file = nothing
end if
set fso = Nothing
...
%>

This should shed a little bit of light on how to do what you want...this moves your file to a backup location....

This will delete the file

<%
set fso = Server.CreateObject("Scripting.FileSystemObject")
if fso.FileExists(FILEPATH) then
          Set file = fso.GetFile(FILEPATH)
          file.Delete True
          set file = nothing
end if
%>

but basically, what you want is that fso.FileExists(FilePath) method

Dan
0
 

Author Comment

by:kevinbenedict
ID: 11677549
This is what I tried...

<%
Set theForm = Server.CreateObject("ABCUpload4.XForm")
theForm.overwrite=True
theForm("filefield")(1).Save "myupload.dat"
%>

I got the same error.

I'll go look at your link.
0
 
LVL 15

Expert Comment

by:joeposter649
ID: 11677921
Maybe you need to use server.MapPath("/myupload.dat")
0
 
LVL 15

Accepted Solution

by:
joeposter649 earned 250 total points
ID: 11679119
Or a capital O in Overwrite.
0

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
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…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

705 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