How to prompt the “Choose a default program” in code?

后端 未结 2 735
南旧
南旧 2020-12-22 05:38

I am writing a program with a listbox filled with items, and when you right click the item, context menu will pop up and have an option to choose call \"Open with\", and my

2条回答
  •  伪装坚强ぢ
    2020-12-22 05:56

    You can use this way to show "Open With" dialog directly:

    string FilePath = "C:\\Text.txt";//Your File Path
    System.Diagnostics.Process proc = new System.Diagnostics.Process();
    proc.EnableRaisingEvents = false;
    proc.StartInfo.FileName = "rundll32.exe";
    proc.StartInfo.Arguments = "shell32,OpenAs_RunDLL " + FilePath;
    proc.Start();
    

提交回复
热议问题