C# Open File With Associated Application passing arguments

前端 未结 3 1059
囚心锁ツ
囚心锁ツ 2021-01-24 19:00


I am trying to launch the default application registered for an extension specifying an additional argument:

 ProcessStartInfo p = new ProcessStartInfo();
          


        
3条回答
  •  南方客
    南方客 (楼主)
    2021-01-24 19:27

    I believe this is expected. Behind the scenes, Windows is finding the default application in the registry and creating a new process and passing your file name to it. I get the same behavior if I go to a command prompt and type "filename.ext argument", that my arguments are not passed to the application.

    What you probably need to do is find the default application yourself by looking in the registry. Then you can start that process with arguments, instead of trying to start by filetype association. There is an answer here on how to find the default application in the registry:

    Finding the default application for opening a particular file type on Windows

提交回复
热议问题