I have a application that opens a file, sends it a printer and then (tries)
to delete it. It is based on the example from Microsoft:
http://support.microsoft.com/?kbid=322091
In my application I have the following code but I always get a file in use
exception when I try to delete the file:
Sub Main(ByVal CmdArgs() As String)
If CmdArgs.Length >= 2 Then
Dim docName = CmdArgs(0)
Dim prName = CmdArgs(1)
Try
RawPrinterHelper.SendFileToPrinter(prName, docName)
Catch ex As Exception
EventLog.WriteEntry("PCLPrinter", "Failed to print PCL file
" & docName & " to printer " & prName & ". More info: " & ex.Message)
End Try
If CmdArgs.Length = 3 Then
If CmdArgs(2) = "/delete" Then
File.Delete(docName)
End If
End If
End If
Is this caused because in the function SendFileToPrinter contains code that
opens a file but does not close it? And how can I close a file?