|
-
Nov 22nd, 2000, 02:56 PM
#1
Thread Starter
New Member
Alright, I just started programming in VB, and here's what's happened so far:
I created a program that will both sort and output an HTML file with named anchors in it based on a fixed length data dump from our system.
The problem is, I did it all sequentially, and had to create a couple documents for workspace in the process. How can I delete these documents from my harddrive when the program closes?
I'm pretty sure I'll do it on a _Terminate() tag, but what goes in the middle? Some of this is secure stuff, and needs to be deleted when the processing is done. HELP!!
-
Nov 22nd, 2000, 03:01 PM
#2
Frenzied Member
Kill yourFileName
will delete your file
-
Nov 22nd, 2000, 03:03 PM
#3
Frenzied Member
-
Nov 22nd, 2000, 03:13 PM
#4
First you should check if it exists else, you'll get an error.
Code:
If Dir$("This File") <> "" Then Kill "This file"
-
Nov 22nd, 2000, 03:22 PM
#5
Thread Starter
New Member
Whether or not it exists
Whether or not it exists is not an issue. . .I know that these files will be created every time, guaranteed.
-
Nov 22nd, 2000, 04:18 PM
#6
Thread Starter
New Member
ITS NOT WORKING
OK, thats not working. . .the files are still there.
Here's the line:
If Dir("c:\TXData.txt") <> "" Then Kill "c:\TXData.txt"
Whats the dealio??
TIA.
-
Nov 22nd, 2000, 04:24 PM
#7
Hyperactive Member
Make sure you close them first.
Here's my Delete File function:
Code:
Public Function DeleteFile(pstrFile As String)
On Error GoTo DeleteFileErr
If InStr(pstrFile, "*") = 0 And InStr(pstrFile, "?") = 0 Then SetAttr pstrFile, vbNormal
Kill pstrFile
DeleteFileExit:
Exit Function
DeleteFileErr:
MsgBox Err.Description, vbInformation, "Notice"
Resume DeleteFileExit
End Function
Here's the function I use to see if a file exists. It doesn't disturb the Dir queue if you are using Dir in the function that calls it:
Code:
Public Function FileExists(pstrFile As String) As Boolean
On Error GoTo FileExistsErr
FileExists = True
If GetAttr(pstrFile) And vbDirectory Then FileExists = False
FileExistsExit:
Exit Function
FileExistsErr:
If Err.Number = 53 Or Err.Number = 75 Then
FileExists = False
Else
MsgBox Err.Description, vbInformation, "Notice"
End If
Resume FileExistsExit
End Function
-
Nov 22nd, 2000, 04:30 PM
#8
Thread Starter
New Member
If the Kill keyword isn't turning blue, doesn't that mean that VB isn't recognizing it as an internal word?
It isn't turning blue by the way. . .
I'm using Visual Studio 6 SP4 by the way. . .don't know if that'll help.
-
Nov 22nd, 2000, 04:35 PM
#9
Hyperactive Member
Its not supposed to. Type it in small letters, if it turns it into Kill then its working
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|