How do I "talk back" to the command line? Using Console.Writeline() doesn't do it. Therefore if the user drags and drops a text file with incorrect formatting it gives no error message, just closes without producing any output.
Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
ServicePointManager.SecurityProtocol = DirectCast(3072, SecurityProtocolType)
'Get command line arguments
Dim lstArgs As List(Of String) = Environment.GetCommandLineArgs.ToList
'1st argument is the application itself, so we can remove that
'and just look at the actual arguments, if any
lstArgs.RemoveAt(0)
'If 1 argument is present, process input file
If lstArgs.Count = 1 Then
If File.Exists(lstArgs(0)) Then
Console.WriteLine("Reading from " & lstArgs(0) & "...")
DrawCommandLine(File.ReadAllText(lstArgs(0)))
End If
'If 2 are present, input file and output filename have been stated
'Filename is optional
ElseIf lstArgs.Count = 2 Then
If File.Exists(lstArgs(0)) Then
strCurrFilename = lstArgs(1)
Console.WriteLine("Reading from " & lstArgs(0) & "...")
Console.WriteLine("Filename will be " & lstArgs(0))
DrawCommandLine(File.ReadAllText(lstArgs(0))) 'File name specified
End If
'No arguments present, user isn't using cmd. Open GUI like normal.
End If
End Sub