我正在使用我的点网代码将一些文件传输到 unix。我要求用户输入他想要传输文件的 unix 路径。在传输文件之前,我想检查用户输入的路径是否有效。
try
{
Process objProcess = new Process();
objProcess.StartInfo.FileName = "putty.exe";
objProcess.StartInfo.Arguments = txtUserName.Text.Trim() + "@" + cmbIP.Text.Trim() + " -pw " + txtPassword.Text.Trim() + " -m \"" + CodeSetFileNameTemp + "\"";
objProcess.Start();
objProcess.WaitForExit();
SUCCEEDED.AppendLine(viewName);
SELECTED.Remove(SELECTED.ToString().IndexOf(viewName), viewName.Length + 2);
}
catch (Exception ex)
{
FAILED.AppendLine(viewName);
SELECTED.Remove(SELECTED.ToString().IndexOf(viewName), viewName.Length + 2);
MessageBox.Show(ex.Message + ". Unable to connect UNIX", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}