I am currently doing the following:
- I create a file using
FileStream
braced in theusing()
tag - Only the file creation takes place within the using statement. The rest of the statements are nearly sequential. - Launch the file I have created using
Process.Start()
- Read a small bit of meta data from the file using
Assembly.ReflectionOnlyLoadFrom()
- List the running processes using
Process.GetProcessesByName
- Kill the Process using
Process.Kill
- Try to delete the file using
File.Delete()
My problem is that my application is locking the file, so when I try to delete it, nothing happens. It throws an exception saying "Access is Denied" if I try to delete, and throws "Another process is using this file" if I try to write to it.
What on earth could be consuming the file from the above (literally all there is)? I have set all references to null
, and gone as far as to call the dreaded GC.Collect()
and no luck.