ShellExecute problem
I have still had the same problem, "the system can't find the file specified." If you have some ideas to fix it, please let me know. Here is the code. The string myDocumentsPath is "C:\MyProject\Documents\" and the string fileName is "myword.doc".
public void OpenDoc(string myDocumentsPath,
string fileName)
{
try
{
string tempFileName = myDocumentsPath + fileName;
Process.Start(tempFileName);
}
catch (Win32Exception e)
{
if(e.NativeErrorCode == ERROR_FILE_NOT_FOUND)
{
Console.WriteLine(e.Message + ". Check the path.");
}
else if (e.NativeErrorCode == ERROR_ACCESS_DENIED)
{
Console.WriteLine(e.Message + ". You do not have permission to open this file.");
}
}
|