I have 2 Filestreams like this:
using (var fs = new FileStream(source, FileMode.Open, FileAccess.Write, FileShare.Read)){
//some code here
var checksum = getChecksum(source);
}
public long getChecksum(string source){
using (var fs = new FileStream(source, FileMode.Open, FileAccess.Read, FileShare.Read)){
//Error: The process cannot access the file 'C:\Temp\archive.dat' because it is being used by another process.
}
}
why does this error appear? I already set the FileAccess to Read / ReadWrite / ... but nothing worked. And I can't pass the Stream to the getChecksum()
function, because I use the function in other places.
shouldn't the above stream allow for reading?
Create 2 FileStream on the same file in the same process I couldn't find my awnser in this thread.