Click here to Skip to main content
11,570,741 members (54,546 online)
   

C#

 
GeneralRe: OT Pin
Peter_in_27803-Oct-12 2:29
memberPeter_in_27803-Oct-12 2:29 
GeneralRe: OT Pin
Dave Kreskowiak3-Oct-12 5:24
mvpDave Kreskowiak3-Oct-12 5:24 
GeneralRe: C# Windows application not responding after 30 minutes Pin
sujithkumarsl3-Oct-12 4:36
membersujithkumarsl3-Oct-12 4:36 
GeneralRe: C# Windows application not responding after 30 minutes Pin
sujithkumarsl3-Oct-12 4:51
membersujithkumarsl3-Oct-12 4:51 
AnswerRe: C# Windows application not responding after 30 minutes Pin
DaveyM693-Oct-12 4:21
mentorDaveyM693-Oct-12 4:21 
GeneralRe: C# Windows application not responding after 30 minutes Pin
sujithkumarsl3-Oct-12 4:41
membersujithkumarsl3-Oct-12 4:41 
GeneralRe: C# Windows application not responding after 30 minutes Pin
DaveyM694-Oct-12 0:34
mentorDaveyM694-Oct-12 0:34 
GeneralRe: C# Windows application not responding after 30 minutes Pin
sujithkumarsl4-Oct-12 10:17
membersujithkumarsl4-Oct-12 10:17 
QuestionTextbox validation c# help Pin
Robbie Kleman2-Oct-12 8:57
memberRobbie Kleman2-Oct-12 8:57 
AnswerRe: Textbox validation c# help Pin
Matt T Heffron2-Oct-12 10:38
memberMatt T Heffron2-Oct-12 10:38 
AnswerRe: Textbox validation c# help Pin
Smart Arab2-Oct-12 11:17
memberSmart Arab2-Oct-12 11:17 
GeneralRe: Textbox validation c# help Pin
Robbie Kleman2-Oct-12 11:27
memberRobbie Kleman2-Oct-12 11:27 
GeneralRe: Textbox validation c# help Pin
Robbie Kleman8-Oct-12 3:37
memberRobbie Kleman8-Oct-12 3:37 
QuestionMonitoring file changes and changing data within the file... Pin
JD862-Oct-12 8:31
memberJD862-Oct-12 8:31 
What would be a good way to monitor a .ini file?

What I want to do is when the file has changed, I need to read the file and find specific text and change it and save the file.

I've attempted the file system watcher with little luck. The problem is it is firing before the file is unlocked. I have also tried to put a method in there to check if the file was locked which basically opens the file and on exception returns true if locked otherwise false.

I have also tried a looping method like this:
private void WriteFile(string file, StringBuilder sb, string oldValue)
        {
            StreamWriter sw = null;
            try
            {
                sw = new StreamWriter(file, false);
                sw.Write(sb.ToString());
                sw.Close();
 
                // Log
                EventLog.WriteEntry("QBiniMonitor", "Successfully removed LASTUSERNAME. Old Value: " + oldValue, EventLogEntryType.Information);
            }
            catch (IOException)
            {
                // Keep trying till the file is unlocked
                WriteFile(file, sb, oldValue);
            }
            finally
            {
                if (sw != null)
                {
                    sw.Close();
                    sw.Dispose();
                }
            }
        }

It still errored out after it changes the value a couple times in a row. It changes it a couple times but then ends up with a uncaught IOException somehow
AnswerRe: Monitoring file changes and changing data within the file... Pin
Smart Arab2-Oct-12 11:22
memberSmart Arab2-Oct-12 11:22 
GeneralRe: Monitoring file changes and changing data within the file... Pin
Pete O'Hanlon3-Oct-12 2:03
protectorPete O'Hanlon3-Oct-12 2:03 
AnswerRe: Monitoring file changes and changing data within the file... Pin
Eddy Vluggen3-Oct-12 1:39
memberEddy Vluggen3-Oct-12 1:39 
AnswerRe: Monitoring file changes and changing data within the file... Pin
Pete O'Hanlon3-Oct-12 2:26
protectorPete O'Hanlon3-Oct-12 2:26 
GeneralRe: Monitoring file changes and changing data within the file... Pin
Dave Kreskowiak3-Oct-12 5:33
mvpDave Kreskowiak3-Oct-12 5:33 
GeneralRe: Monitoring file changes and changing data within the file... Pin
Pete O'Hanlon3-Oct-12 5:37
protectorPete O'Hanlon3-Oct-12 5:37 
GeneralRe: Monitoring file changes and changing data within the file... Pin
Dave Kreskowiak3-Oct-12 13:38
mvpDave Kreskowiak3-Oct-12 13:38 
AnswerRe: Monitoring file changes and changing data within the file... Pin
BobJanova3-Oct-12 2:42
memberBobJanova3-Oct-12 2:42 
GeneralRe: Monitoring file changes and changing data within the file... Pin
Pete O'Hanlon3-Oct-12 3:10
protectorPete O'Hanlon3-Oct-12 3:10 
GeneralRe: Monitoring file changes and changing data within the file... Pin
JD863-Oct-12 13:59
memberJD863-Oct-12 13:59 
GeneralRe: Monitoring file changes and changing data within the file... Pin
JD8612-Oct-12 5:27
memberJD8612-Oct-12 5:27 
QuestionC# setup and deploy project templates located at? Pin
dcof2-Oct-12 5:10
memberdcof2-Oct-12 5:10 
AnswerRe: C# setup and deploy project templates located at? Pin
isenthil2-Oct-12 6:30
memberisenthil2-Oct-12 6:30 
GeneralRe: C# setup and deploy project templates located at? Pin
dcof2-Oct-12 17:48
memberdcof2-Oct-12 17:48 
GeneralRe: C# setup and deploy project templates located at? Pin
Dave Kreskowiak3-Oct-12 2:28
mvpDave Kreskowiak3-Oct-12 2:28 
AnswerRe: C# setup and deploy project templates located at? Pin
Dave Kreskowiak2-Oct-12 12:33
mvpDave Kreskowiak2-Oct-12 12:33 
Questionsyntax Pin
messages2-Oct-12 4:29
membermessages2-Oct-12 4:29 
AnswerRe: syntax Pin
Eddy Vluggen2-Oct-12 4:31
memberEddy Vluggen2-Oct-12 4:31 
GeneralRe: syntax Pin
messages2-Oct-12 5:28
membermessages2-Oct-12 5:28 
AnswerRe: syntax Pin
Richard MacCutchan2-Oct-12 5:54
mvpRichard MacCutchan2-Oct-12 5:54 
GeneralRe: syntax Pin
messages2-Oct-12 6:09
membermessages2-Oct-12 6:09 
Questionmultiple loading of assemblies - does it have any associated problems? Pin
Dan_K2-Oct-12 2:53
memberDan_K2-Oct-12 2:53 
AnswerRe: multiple loading of assemblies - does it have any associated problems? Pin
Eddy Vluggen2-Oct-12 3:23
memberEddy Vluggen2-Oct-12 3:23 
GeneralRe: multiple loading of assemblies - does it have any associated problems? Pin
Dan_K2-Oct-12 3:29
memberDan_K2-Oct-12 3:29 
AnswerRe: multiple loading of assemblies - does it have any associated problems? Pin
Eddy Vluggen2-Oct-12 4:29
memberEddy Vluggen2-Oct-12 4:29 
AnswerRe: multiple loading of assemblies - does it have any associated problems? Pin
jschell2-Oct-12 8:42
memberjschell2-Oct-12 8:42 
AnswerRe: multiple loading of assemblies - does it have any associated problems? Pin
Dave Kreskowiak2-Oct-12 12:29
mvpDave Kreskowiak2-Oct-12 12:29 
SuggestionRe: multiple loading of assemblies - does it have any associated problems? Pin
Guirec Le Bars2-Oct-12 18:11
memberGuirec Le Bars2-Oct-12 18:11 
GeneralRe: multiple loading of assemblies - does it have any associated problems? Pin
jschell3-Oct-12 10:16
memberjschell3-Oct-12 10:16 
AnswerRe: multiple loading of assemblies - does it have any associated problems? Pin
BobJanova3-Oct-12 5:05
memberBobJanova3-Oct-12 5:05 
QuestionWhen to use .PerformClick() Pin
MAW301-Oct-12 15:07
memberMAW301-Oct-12 15:07 
AnswerRe: When to use .PerformClick() Pin
DaveyM691-Oct-12 16:05
mentorDaveyM691-Oct-12 16:05 
GeneralRe: When to use .PerformClick() Pin
MAW301-Oct-12 16:55
memberMAW301-Oct-12 16:55 
AnswerRe: When to use .PerformClick() Pin
Dave Kreskowiak2-Oct-12 1:32
mvpDave Kreskowiak2-Oct-12 1:32 
GeneralRe: When to use .PerformClick() Pin
DaveyM692-Oct-12 3:02
mentorDaveyM692-Oct-12 3:02 
AnswerRe: When to use .PerformClick() Pin
Ravi Bhavnani2-Oct-12 6:22
memberRavi Bhavnani2-Oct-12 6:22 

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

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


Advertise | Privacy | Mobile
Web03 | 2.8.150624.2 | Last Updated 1 Jul 2015
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid