Deleting Files

lothos12345

Well-known member
Joined
May 2, 2002
Messages
294
Location
Texas
Is there a quick way I can delete all the files in a folder using VB.NET. Any help is greatly apprieciated. Also using an inputbox is there a way I can make the text typed appear to be as "*".
 
for the first one something like
Code:
dim files() as string = System.io.directory.GetFiles("c:\")    change as appropriate

dim file as string
for each file in files
system.io.file.delete(file)
next

for the second IIRC textboxes have a password character - just set that to * and it should work
 
Is the file in use ? :D Are these files you are creating within your application? If so are you closing all the streams / streamreaders down after you have finished with them - if not these will keep the files open.
If they are not files used by your app then what files are they - another app could have them locked.
 
I am doing both. I process an Acrobat doc and close the doc AND exit the Acrobat app. I also create a log file that I Flush and Close. But when I call file.delete on either file, I get the error.

???
 
I cant seem to get my Adobe objects to release a file so I can delete it when Im done with it.
I am using VB.NET:
we need delete (temporary) PDF...
close all objects that reference PDF
On Error Resume Next
If Not oAcroDoc Is Nothing Then
oAcroDoc.Close()
endif
oAcroDoc = Nothing
System.Runtime.InteropServices.Marshal.ReleaseComObject(oAcroDoc)
If Not oAcroAVDoc Is Nothing Then
oAcroAVDoc.Close(True)
endif
oAcroAVDoc = Nothing
System.Runtime.InteropServices.Marshal.ReleaseComObject(oAcroAVDoc)
If Not oAcroExch Is Nothing Then
oAcroExch.CloseAllDocs()
endif
oAcroExch.Exit()
oAcroExch = Nothing
System.Runtime.InteropServices.Marshal.ReleaseComObject(oAcroExch)
System.GC.Collect()
delete the file
File.Delete(sNewFileName)

Errors out with "File in use by another process..."

Any suggestions?

GEM
 
Back
Top