Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
File Access
Message
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Titre:
File Access
Divers
Thread ID:
00857018
Message ID:
00857018
Vues:
53
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform