1

When double-clicking on a file with an unknown file type, windows will bring up a window that allows me to select which application I want to open the file with.

I am trying to open files in my application using the following code and I was getting the same result until recently

   var startInfo = new ProcessStartInfo(document.DownloadPath);
   startInfo.UseShellExecute = true;
   Process.Start(startInfo);                  

I don't know when it stopped working, as I moved on to other parts of the application, but now I get the following error when trying to open a file with an unknown extension.

System.ComponentModel.Win32Exception (1155): No application is associated with the specified file for this operation.
   at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)
   at System.Diagnostics.Process.Start()
   at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)

How can I get the same experience when opening with my application or actually double-clicking on the file?

spovelec
  • 369
  • 1
  • 4
  • 20
  • 1
    https://stackoverflow.com/questions/4726441/how-can-i-show-the-open-with-file-dialog – Hans Passant Mar 25 '21 at 01:31
  • @HansPassant This will ask for all files. I only want it to ask for files that it is not sure of. My code used to work in .net framework apps that I have written. Not sure why it would not be working now on .net 3.1. – spovelec Mar 25 '21 at 01:50
  • Possible duplicate of https://stackoverflow.com/questions/884012/how-to-bring-up-the-windows-cannot-open-this-file-dialog – mma Nov 07 '22 at 14:06

0 Answers0