public static bool OpenPress(string FileName, string Arguments)//開啟外部檔案
{
Process pro = new Process();
if (System.IO.File.Exists(FileName))
{
//設定工作目錄為當前工作目錄
string sPath = string.Empty;
sPath = Path.GetDirectoryName(FileName).ToString();
System.IO.Directory.SetCurrentDirectory(sPath);
pro.StartInfo.FileName = FileName;
pro.StartInfo.Arguments = Arguments;
pro.StartInfo.CreateNoWindow = true;
pro.StartInfo.UseShellExecute = false;
pro.StartInfo.RedirectStandardInput = true;
pro.StartInfo.RedirectStandardOutput = true;
pro.StartInfo.CreateNoWindow = true;
pro.Start();
//切換為原工作目錄
System.IO.Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory);
return true;
}
return false;
}