0

这是我的代码

      if (row.Cells[5].Value.ToString().ToUpper() == "JPG")
      {
          try 
          {
         //     string notepadPath = Path.Combine(Environment.SystemDirectory, "MSPAINT.exe");
              string notepadPath = Path.Combine(Environment.SystemDirectory, "JPEGViewer.exe");
              if (File.Exists(notepadPath))
                  Process.Start(notepadPath, location);
              else
                  throw new Exception("Can't locate Notepad");
          }
          catch (Exception ee)
          {
              MessageBox.Show("Exception is " + ee.Message);
          }
      }

即使字符串 notepadPath 包含文件夹和可执行文件C:\Windows\system32\JPEGViewer.exe 行 ** if (File.Exists(notepadPath))即使它在那里也找不到该 exe。如果我试图绕过 Exist 并执行 Process.Start(notepadPath, location);It throws an exception系统找不到指定的文件 **

请注意,调用MSPAINT.EXE时,同样的代码可以完美运行

任何想法将不胜感激,

4

0 回答 0