G
Guest
Ok, so I have one program that has locked a file while it is being written to
disk.
lock (typeof(StreamWriter))
{
using (StreamWriter sw = new StreamWriter("C:\\Test\\filename.txt"))
{
sw.WriteLine("test text");
sw.Close();
}
}
Now, I have another program that is trying to access the same file
(filename.txt).
using (StreamReader sr = new StreamReader("C:\\Test\\filename.txt"))
{
sr.ReadLine("test text");
sr.Close();
}
How can the second program test to see if the first program still has
(filename.txt) locked? I need the data in the second program before moving
to the next step.
disk.
lock (typeof(StreamWriter))
{
using (StreamWriter sw = new StreamWriter("C:\\Test\\filename.txt"))
{
sw.WriteLine("test text");
sw.Close();
}
}
Now, I have another program that is trying to access the same file
(filename.txt).
using (StreamReader sr = new StreamReader("C:\\Test\\filename.txt"))
{
sr.ReadLine("test text");
sr.Close();
}
How can the second program test to see if the first program still has
(filename.txt) locked? I need the data in the second program before moving
to the next step.