Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deleting a text file in another directory 2

Status
Not open for further replies.

doswald

Programmer
Aug 15, 2000
1
US
I am trying to export a file from ACCESS into a text file that already exists and am having authority problems.  I find that I can export to a new file but cannot replace an existing file.  I would like to know how to delete an existing file from with a VB program.
 
What you could do is the kill statement if the file exists.<br><br>Public Sub KillThatFile()<br><br>sFileName = &quot;killme.adtg&quot;<br>sFileExists = Dir(sFileName)<br><br>If sFileExists = Dir(sFileName) Then<br>&nbsp;&nbsp;&nbsp;Kill (sFileName)<br>End If<br><br>End Sub<br><br>Hope this helps.<br><br><br>
 
Another $.02<br><br><FONT FACE=monospace><br>Public function KillThatFile(sFilename)<br>&nbsp;&nbsp;on error resume NotDeleted<br><b><br>&nbsp;&nbsp;If&nbsp;&nbsp;&quot;&quot; &lt;&gt; Dir(sFileName) Then Kill sFileName<br>&nbsp;&nbsp;KillThatFile = TRUE<br></b><br>ExitFun: <br>&nbsp;&nbsp;on error goto 0<br>&nbsp;&nbsp;exit function<br><br>NotDeleted:<br>&nbsp;&nbsp;KillThatFile = FALSE<br>&nbsp;&nbsp;resume ExitFun<br><br>End function<br></font><br><br><br>If the problem is in File system authorities, for example you only have add and change rights to the directory.&nbsp;&nbsp;You need to get with the system's administrator.<br><br><br><br>Programmers axiom #4 -- When paid by the line, always handle&nbsp;&nbsp;errors.<br><br> <p>Wil Mead<br><a href=mailto:wmead@optonline.net>wmead@optonline.net</a><br><a href= > </a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top