lothos12345 Posted February 25, 2004 Posted February 25, 2004 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 "*". Quote
Administrators PlausiblyDamp Posted February 25, 2004 Administrators Posted February 25, 2004 for the first one something like 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 Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
gmccartney Posted March 4, 2004 Posted March 4, 2004 In use? But why do I get a "file in use" error when I try to delete files? :confused: GEM Quote
Heiko Posted March 4, 2004 Posted March 4, 2004 That's probably the same as if you'd delete it with the explorer. Some other process has opened the file so you can't delete it. Quote .nerd
Administrators PlausiblyDamp Posted March 4, 2004 Administrators Posted March 4, 2004 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. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
gmccartney Posted March 4, 2004 Posted March 4, 2004 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. ??? Quote
gmccartney Posted March 4, 2004 Posted March 4, 2004 Well! I got my text file to close, now if I can just get the Adobe file to close... GEM Quote
gmccartney Posted March 4, 2004 Posted March 4, 2004 I can't seem to get my Adobe objects to release a file so I can delete it when I'm 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 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.