Nicezia, I've added you on gtalk. Request from plyoung will be me.
I found some IO errors which seems to be comming from the logging stuff, but I'm still investigating this. Seems like LogFileInfo.Create(); can keep FileStream LogFile = new FileStream(LogFilePath, FileMode.Append); from opening the file in some cases.
[edit] Did moretesting and here is what I found.
The error message is "The process cannot access the file 'C:\Work\xMM\xMM\bin\Debug\test.log' because it is being used by another process." which happens on FileStream LogFile = new FileStream(testfile, FileMode.Append);
From this it might happend that this exception will be thrown when you try to write to the log after a call to VerifyLogFile(...)
Code:
private void test1()
{
string testfile = Application.StartupPath + Path.DirectorySeparatorChar.ToString() + "test.log";
//try
{
FileInfo LogFileInfo = new FileInfo(testfile);
LogFileInfo.Create();
}
//catch { }
}
private void test2()
{
string testfile = Application.StartupPath + Path.DirectorySeparatorChar.ToString() + "test.log";
//try
{
FileStream LogFile = new FileStream(testfile, FileMode.Append);
StreamWriter sw = new StreamWriter(LogFile);
sw.WriteLine("{0} : {1}", DateTime.Now.ToString("yyyy/MM/dd - HH:mm:ss"), "test");
sw.Close();
LogFile.Close();
}
//catch { }
}
private void MainForm_Load(object sender, EventArgs e)
{
test1();
test2();
...
[edit2] Rather than using
Code:
FileInfo LogFileInfo = new FileInfo(testfile);
LogFileInfo.Create();
to create the file, use this. Seems to work. I'd still add the try catch block just incase.
Code:
FileStream f = File.Create(testfile);
f.Close();
But I don't think this code is even needed since FileStream LogFile = new FileStream(testfile, FileMode.Append); seems to create the file if it does not exist.