I am trying to convert one of my unix text files to a dos text file. I am using the following command:
Shell(string.format("unix2dos {0}", sFileCompletePath))
I've already added the unix2dos command in my environment path on the server.
But when I execute the above mentioned command I get a FileNotFound exception even when the file is located on the disk.
Is there anything I am missing out?
I would recommend doing it this way:
Public Sub ShellandWait(ByVal ProcessPath As String, ByVal Arguments As String)
Dim objProcess As System.Diagnostics.Process
Try
objProcess = New System.Diagnostics.Process()
objProcess.StartInfo.Arguments = Arguments
objProcess.StartInfo.FileName = ProcessPath
objProcess.StartInfo.WindowStyle = ProcessWindowStyle.Maximized
objProcess.Start()
'Wait until it's finished
objProcess.WaitForExit()
'Exitcode as String
Console.WriteLine(objProcess.ExitCode.ToString())
objProcess.Close()
Catch ex As Exception
Console.WriteLine("Could not start process " & ProcessPath & " " & ex.Message.ToString)
End Try
End Sub
It's more complicated but gives you more power over your processes.
If sFileCompletePath
contains spaces, it could solve it by adding double quotes around it:
Shell(String.Format("unix2dos ""{0}""", sFileCompletePath))
If you want to have more control over the process, it might be better to use the example Chris posted.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.