I've seen many issues like this that have been solved and the problem was mostly due to streams not being disposed of properly.
My issue is slightly different, here follow a code snippet
foreach (Images item in ListOfImages)
{
newPath = Path.Combine(newPath, item.ImageName + item.ImageExtension);
File.Create(newPath);
File.WriteAllBytes(newPath, item.File);
}
Where Images
is a custom struct and item.File
is the raw data, byte[].
My issue is that at the line where the WriteAllBytes
is called, an exception is thrown. The message reads:
The process cannot access the file because it is being used by another process
Again I have no clue how am I going to somehow close
the process.
File.Create(newPath);
and try. File.WriteAllBytes:Creates a new file, writes the specified byte array to the file, and then closes the file. If the target file already exists, it is overwritten.
msdn.microsoft.com/en-us/library/… – Remiss