Pregunta

I am creating a VB app which will "move" xls reports from a directory to a ReportSafe app. I am also working in an existing VB app which does just that, so I am using it for reference.

It isn't as simple as moving files from one directory to another, because ReportSafe requires an lpr command to tell it (ReportSafe) which file to pick up.

Here is what I have so far:

Imports System.IO
Module Module1

Sub Main()

    ''Declarations
    Dim Files As ArrayList = New ArrayList()
    Dim FileName As String

    ''Write All Files in *directory* to ReportSafe
    Files.Clear()
    Files.AddRange(Directory.GetFiles(*directory*))
    For Each FileName In Files

        Dim RPname As String
        Dim RealName As String
        RPname = FileName.ToString
        RealName = "/"
        RealName = RealName & RPname.Remove(0, 34)

        Dim a As New Process
        a.StartInfo.FileName = "C:\Windows\system32\lpr.exe"
        a.StartInfo.Arguments = "-S*ServerName* -Plp -J" & Chr(34) & RealName & Chr(34) & " " & Chr(34) & RPname & Chr(34)
        a.StartInfo.UseShellExecute = False

    Next
End Sub

End Module

The whole lpr command/arguments are throwing me for a loop. I'm not sure if my question is specific to ReportSafe, and if that's the case, I may be out of luck here. I have pulled this code from the already existing app which moves reports to ReportSafe, and adjusted for my own use, but no luck so far.

FYI, I had to turn on LPR Monitor services to obtain to the lpr.exe

Questions: What are the proper arguments to pass through to this lpr command? Is there a problem with the logic that is causing the issue?

¿Fue útil?

Solución

I continued to tinker and look at my reference code and discovered some flaws in logic:

For one, the report name I was passing did not include the complete file path. Another thing is that I never started the process with a.Start(). Rookie mistakes for sure... haha

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top