public string OpenFile(string fileName)
{
string result = "success";
string path = System.IO.Path.GetDirectoryName(
System.Windows.Forms.Application.ExecutablePath) + "\\" + fileName;
const int ERROR_FILE_NOT_FOUND = 2;
System.Diagnostics.Process myProcess = new System.Diagnostics.Process();
try
{
myProcess.StartInfo.FileName = path;
myProcess.StartInfo.Verb = "Open";
myProcess.StartInfo.CreateNoWindow = true;
myProcess.Start();
}
catch (System.ComponentModel.Win32Exception ex1)
{
result = "error";
if (ex1.NativeErrorCode == ERROR_FILE_NOT_FOUND)
result += ", " + ex1.Message;
}
catch (Exception ex2)
{
result = "error, " + ex2.Message;
}
return result;
}
留言列表