Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
File Access
Message
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Titre:
Divers
Thread ID:
00857018
Message ID:
00857235
Vues:
34
How do you set the string reader to readonly?
I have tried IO.File.OpenText and IO.File.OpenRead which the documentation sugests opens a file for read. I have also given the ASPNET account read and file scan permissions to that folder.

>>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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform