title: using File.Open(parameters and File.Read(path).Last()
body: <p>i'm working on a project in c# and need to be able to read the last line of a text file in use before processing for other activities. here is my code sample. The File.Open works fine by itself and so does the ReadLines(path).Last(). Together, they don't work. I'm new to C# and would appreciate any help given.  Thanks</p>
  
  <pre><code> string g = "C:\\zebra\\file.txt";
  
   File.Open (g, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);                                    
  
  string  file_name = File.ReadLines(g).Last();// error of being unable to access file because it's in use
  
              Thread.Sleep(50);
  
              Name.Text = file_name.Substring(13); 
              ID.Text = file_name.Substring(8, 5);
  </code></pre>