ex.Message is: The process cannot access the file '\\ffgenv\docenv\FFG\DPBatch_Error.Log' because it is being used by another process.
Below is the code:
Public Sub ErrorFileProcess(ByVal strErrData As String, ByVal intMyErrNum As Integer, ByVal strFileNamePath As String)
blnErrorHit = True
Dim strErrBeginText As String
Try
If System.IO.File.Exists(strFileNamePath) = True Then
Using writer As StreamWriter = New StreamWriter(strFileNamePath, True)
writer.WriteLine("Err Msg: " & strErrData & " Err Num: " & intMyErrNum)
writer.Close()
End Using
Else
Using writer As StreamWriter = New StreamWriter(strFileNamePath)
"DocPrint Batch ERROR Report" & vbCrLf
strErrBeginText =
writer.WriteLine(strErrBeginText)
strErrBeginText = "Date Time Created: " & System.DateTime.Now & vbCrLf & vbCrLf
writer.WriteLine(strErrBeginText)
strErrBeginText = "ERROR MESSAGE" & vbCrLf
writer.WriteLine(strErrBeginText)
writer.WriteLine("Err Msg: " & strErrData & " Err Num: " & intMyErrNum)
writer.Close()
End Using
End If
Catch ex As Exception
"Exception from ErrorFileProcess where ex.Message is: " & ex.Message) 'this is the error module, its the end of the line, so all I can think to do is send email at this point
ErrorEmail(
End Try
VulpesPosted Aug 28, 2012, 6:36 PM
That way the original will still be available to write to.
George GilbertPosted Sep 2, 2012, 11:47 AM
VulpesPosted Sep 2, 2012, 10:26 AM
George GilbertPosted Sep 1, 2012, 6:36 PM
VulpesPosted Sep 1, 2012, 6:30 PM
George GilbertPosted Sep 1, 2012, 5:48 PM
Patricia KolbPosted Aug 29, 2012, 4:19 PM
Patricia KolbPosted Aug 28, 2012, 12:06 PM
Dim msg1.Attachments.Add(myAttachment)
myAttachment As Net.Mail.Attachment = New Net.Mail.Attachment(strFileName)VulpesPosted Aug 28, 2012, 5:09 AM
Are you sure that after the initial write you're not opening the file in some other program, which is the only reason I can think of why you'd get this exception?