Click here to Skip to main content
15,897,273 members
Home / Discussions / C#
   

C#

 
AnswerRe: Putting a copyright symbol in a label Pin
Ravi Bhavnani29-Aug-06 12:34
professionalRavi Bhavnani29-Aug-06 12:34 
QuestionDisable Tab clicks Pin
Saamir29-Aug-06 8:24
Saamir29-Aug-06 8:24 
AnswerRe: Disable Tab clicks Pin
ventomito29-Aug-06 9:20
ventomito29-Aug-06 9:20 
QuestionLogin for application Pin
vineas29-Aug-06 6:36
vineas29-Aug-06 6:36 
AnswerRe: Login for application Pin
Not Active29-Aug-06 10:01
mentorNot Active29-Aug-06 10:01 
GeneralRe: Login for application Pin
vineas29-Aug-06 10:58
vineas29-Aug-06 10:58 
GeneralRe: Login for application Pin
Not Active29-Aug-06 11:05
mentorNot Active29-Aug-06 11:05 
QuestionStupid, stupid problem Pin
gantww29-Aug-06 5:48
gantww29-Aug-06 5:48 
Ok,
I can not for the life of me figure out what is going on here. The problem is that another process is locking one of the files I am trying to read. All I want to do is get the contents of the file and parse them. I'm not writing to the file at all. How can I make this thing work? The only option I can think of is to make a temporary copy of the file and then open that, but that seems rather hackish. The process locking the file is mission critical and runs for hours.

This program is essentially an attempt on my part to periodically parse the logs and notify me if there are errors.

I have the following function:

static string GetFileContents(string fileName)
{
bool success = false;
string ret = string.Empty;
FileInfo fi = new FileInfo(fileName);

while(!success)
{
try
{
using(FileStream fs = fi.Open(FileMode.Open, FileAccess.Read))
{
Console.WriteLine("Reading File {0}", fi.Name);

using(StreamReader sr = new StreamReader(fs))
{
ret = sr.ReadToEnd();
}
fs.Close();
success = true;
}
}
catch(Exception ex)
{
//Some sort of problem reading the file - we'll wait and then try again.
Console.WriteLine("Trouble reading file {0} - Will wait 5 minutes and try again. {1}", fi.Name,DateTime.Now);
System.Diagnostics.Debug.WriteLine(ex);
Thread.Sleep(300000);
}
}
return ret;
}
QuestionRe: Stupid, stupid problem Pin
Nader Elshehabi29-Aug-06 6:32
Nader Elshehabi29-Aug-06 6:32 
QuestionMultiple instance of Control (Class Library) Pin
Maddie from Dartford29-Aug-06 5:09
Maddie from Dartford29-Aug-06 5:09 
QuestionGetWindowText API? Pin
wbjohnson29-Aug-06 4:58
wbjohnson29-Aug-06 4:58 
AnswerRe: GetWindowText API? Pin
Dave Kreskowiak29-Aug-06 7:30
mveDave Kreskowiak29-Aug-06 7:30 
GeneralRe: GetWindowText API? Pin
wbjohnson29-Aug-06 7:39
wbjohnson29-Aug-06 7:39 
GeneralRe: GetWindowText API? Pin
Dave Kreskowiak29-Aug-06 9:20
mveDave Kreskowiak29-Aug-06 9:20 
GeneralRe: GetWindowText API? Pin
wbjohnson29-Aug-06 12:03
wbjohnson29-Aug-06 12:03 
QuestionApplication Blocks Help Pin
Brendan Vogt29-Aug-06 4:39
Brendan Vogt29-Aug-06 4:39 
AnswerRe: Application Blocks Help Pin
Not Active29-Aug-06 10:11
mentorNot Active29-Aug-06 10:11 
GeneralRe: Application Blocks Help Pin
Brendan Vogt29-Aug-06 20:35
Brendan Vogt29-Aug-06 20:35 
GeneralRe: Application Blocks Help Pin
Not Active30-Aug-06 3:11
mentorNot Active30-Aug-06 3:11 
Questionsql timeout Pin
JacquesDP29-Aug-06 4:27
JacquesDP29-Aug-06 4:27 
AnswerRe: sql timeout Pin
Baj2229-Aug-06 5:12
Baj2229-Aug-06 5:12 
GeneralRe: sql timeout Pin
JacquesDP29-Aug-06 5:33
JacquesDP29-Aug-06 5:33 
AnswerRe: sql timeout Pin
J4amieC29-Aug-06 5:41
J4amieC29-Aug-06 5:41 
GeneralRe: sql timeout Pin
JacquesDP29-Aug-06 18:38
JacquesDP29-Aug-06 18:38 
GeneralRe: sql timeout Pin
JacquesDP29-Aug-06 18:43
JacquesDP29-Aug-06 18:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.