Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
File Access
Message
General information
Forum:
ASP.NET
Category:
Other
Title:
Miscellaneous
Thread ID:
00857018
Message ID:
00857030
Views:
28
>I am using the following procedure to attempt to read the most recent line in the www and ftp log files (\winnt\system32\Logfiles\W3SVC1\) but the catch statement reports the file is cannot be read because it is in use by another process. I assume this other process is IIS, but notepad and other file reading utilities can read these files fine. How can I accomplish the same in .NET?
>
>
>		private string LastFileLine (System.IO.FileInfo fi)
>		{
>			string LastLine = "";
>			try
>			{
>				System.IO.StreamReader sr = System.IO.File.OpenText(fi.FullName);
>				string line;
>				while ((line = sr.ReadLine()) != null)
>				{
>					LastLine = line;
>				}
>				sr.Close();
>			}
>			catch (Exception ex)
>			{
>				LastLine=ex.Message;
>			}
>			return LastLine;
>		}
>
>
>Thanks in advance,
>Troy
I think you can just set the StringReader to ReadOnly Mode and you should be able to.

Morgan
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform