0

I am using C# in Windows 11.
PhotoViewer is the default app for AVI files on my PC. I am trying to launch PhotoViewer with an AVI file using the "Process.Start" method as follows:

MessageBox.Show(fn + " exists? " + File.Exists(fn));
Process.Start("@" + fn);

The MessageBox output is "d:\dscf0001.avi exists? true."
Process.Start throws a Win32Exception with the message "The system cannot find the file specified."
What am I doing wrong?

bob72
  • 1
  • 1

1 Answers1

0

I guess you have read from the internet, something like

Process.Start(@"D:\document.pdf");

They put the @ at the beginning because the character \ is the escape character and it needs to be disabled by @.

Refer:

https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/tokens/verbatim

https://www.tutorialsteacher.com/csharp/csharp-string

In your case, you don't need it.

Process.Start(fn);
Võ Quang Hòa
  • 2,688
  • 3
  • 27
  • 31