DarkConsultant
Programmer
Hi Everyone,
This should be my last question before I get my eyes done (cataracts) so please wish me well and tell me why ....
I have an app that uses a common, network folder for logging. All clients connect to the shared folder via Mapped Network Drive letters and save logging to a file for example 'F:\Logs\2009\12\01.txt'.
When a log entry is written ...
Public Sub WriteLogEntry(ByVal LogEntry as String)
Dim MyLogFile as String = "F:\Logs\2009\12\01.txt"
Try
Try
If Directory.Exists(Path.GetDirectoryName(MyLogFile)) = False Then
Directory.Create(Path.GetDirectoryName(MyLogFile))
End If
Catch ex As Exception
1 * FAILS HERE
End Try
Dim Exists As Boolean = File.Exists(MyLogFile)
Using LogFile As New StreamWriter(MyLogFile,Exists)
LogFile.WriteLine(LogEntry)
End Using
Catch ex As Exception
2 * FAILS HERE
End Try
End Sub
The code above fails at fail point 1 on around 15% of clients with the error message
System.IO.DirectoryNotFoundException: Could not find a part of the path \'F:\\CCTraining\\System\\Logs\\2009\\12\'.
and at fail point 2
System.IO.DirectoryNotFoundException: Could not find a part of the path \'F:\\CCTraining\\System\\Logs\\2009\\12\\01 Log.txt\'.
AND the file does not get written to.
85% of clients are fine and never error.
I have searched on Google and here but my eyes prevent me from reading most of it and so I cannot resolve the problem.
Many thanks
DarkConsultant
Live long and prosper \\//
This should be my last question before I get my eyes done (cataracts) so please wish me well and tell me why ....
I have an app that uses a common, network folder for logging. All clients connect to the shared folder via Mapped Network Drive letters and save logging to a file for example 'F:\Logs\2009\12\01.txt'.
When a log entry is written ...
Public Sub WriteLogEntry(ByVal LogEntry as String)
Dim MyLogFile as String = "F:\Logs\2009\12\01.txt"
Try
Try
If Directory.Exists(Path.GetDirectoryName(MyLogFile)) = False Then
Directory.Create(Path.GetDirectoryName(MyLogFile))
End If
Catch ex As Exception
1 * FAILS HERE
End Try
Dim Exists As Boolean = File.Exists(MyLogFile)
Using LogFile As New StreamWriter(MyLogFile,Exists)
LogFile.WriteLine(LogEntry)
End Using
Catch ex As Exception
2 * FAILS HERE
End Try
End Sub
The code above fails at fail point 1 on around 15% of clients with the error message
System.IO.DirectoryNotFoundException: Could not find a part of the path \'F:\\CCTraining\\System\\Logs\\2009\\12\'.
and at fail point 2
System.IO.DirectoryNotFoundException: Could not find a part of the path \'F:\\CCTraining\\System\\Logs\\2009\\12\\01 Log.txt\'.
AND the file does not get written to.
85% of clients are fine and never error.
I have searched on Google and here but my eyes prevent me from reading most of it and so I cannot resolve the problem.
Many thanks
DarkConsultant
Live long and prosper \\//