I'm trying to figure out a way to lock multiple files at the same time. For example, I want to lock test1.txt test2.txt but not lock the rest of the files in the folder.
I currently lock the files by using:
FileStream fileStream = new FileStream("C:\\pathoffile\test1.txt", FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
StreamReader streamReader = new StreamReader(fileStream);
fileStream.Lock();
//this is where i check if the file is indeed locked or not
streamReader.Close();
fileStream.Close();
This works perfectly fine, however I do not want to do this for every file that I lock. I was wondering if there was a simpler way to lock multiple files at once?
Thanks