1

I want to start notepad, using a filename the user chose from a document list I already provided using Process.Start. When I use that method it is throwing the error "The system cannot find the file specified".

My code:

 ProcessStartInfo startInfo = new ProcessStartInfo();
 startInfo.FileName = @"C:\WINDOWS\system32\notepath.exe";
 startInfo.Arguments = @"C:\folder\a.txt";
 Process.Start(startInfo);    
Foitn
  • 604
  • 6
  • 25
Dakmaz
  • 429
  • 1
  • 7
  • 16
  • 4
    Are you looking for notepad.exe not notepath.exe? – Bali C Sep 21 '11 at 08:37
  • I think in asp.net, we do server mapping by calling Server.MapPath() something. I am not sure what exactly is the name of function. You can't use this mapping in an ASP.NET application – Pankaj Upadhyay Sep 21 '11 at 08:37
  • 2
    i think you mean `notepad.exe` ? Also won't just reading the file and displaying the contents do for you – V4Vendetta Sep 21 '11 at 08:38
  • Make sure the files *C:\WINDOWS\system32\notepath.exe* and *C:\folder\a.txt* exist on your computer. – Otiel Sep 21 '11 at 12:02
  • Note for reviewers: IMO, the 'possible duplicate' above has nothing to do with this question (issue there is spaces in filename, issue here is probably incorrect exe name) – Peter B Apr 04 '18 at 13:18

3 Answers3

0

How about this? By doing this you also makes sure that your file will appear even if the path contains whitespacing

var proc = new Process
{
    StartInfo = new ProcessStartInfo
    {
        FileName = @"C:\Windows\System32\notepad.exe",
        Arguments = $"\"{filePath}\"",
    }
};
proc.Start();

*You used notepath.exe, I think you would like to use notepad.exe, therefore I changed the executables name!

Foitn
  • 604
  • 6
  • 25
0

try this

ProcessStartInfo info = new ProcessStartInfo(@"C:\WINDOWS\system32\notepath.exe");

Go here for further details

Community
  • 1
  • 1
ayush
  • 14,350
  • 11
  • 53
  • 100
0

"I want to show document list that is in a folder with using 'process.start' method." That is simply wrong.

To list files present in a folder, use Directory.GetFiles()

Otiel
  • 18,404
  • 16
  • 78
  • 126
  • i show list(using directory.getfiles..) when a user select the list item, i want to show document with using process.start(..) – Dakmaz Sep 21 '11 at 10:30