Jump to content
Xtreme .Net Talk

Recommended Posts

Posted
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 "*".
  • Administrators
Posted

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

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted

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.

.nerd
  • Administrators
Posted

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.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted

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.

 

???

Posted

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...