troubleshooting Question

system.io.path.GetTempFileName - Can't delete it!

Avatar of purejamie
purejamieFlag for United Kingdom of Great Britain and Northern Ireland asked on
Visual Basic.NET
8 Comments1 Solution886 ViewsLast Modified:
Hello Experts,

Hopefully this one will be an easy one for someone!

I am creating a temp file using  'system.io.path.gettempfilename' to use within a sub, however, when I try to delete it at the end of the sub it returns the message - "The process can not acces the file <filename I  created earlier> because it is being used by another process" . In a nutshell, the code would look like this:

dim strFilename as string = system.io.path.gettempfilename

<Do stuff with the file, in this case using it to generate new transforms for MSI's>

system.io.file.delete(strfilename)

I have tried using marshal and garbage collection to release the file for deletion with no luck. Any Comcontrol's etc. that could possibly be holding the file open are also closed. Any help would be greatly appreciated.

Cheers,
Jamie.
ASKER CERTIFIED SOLUTION
graye

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 8 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros