![](/img/trans.png)
[英]Accessing a file which is opened by another exe (opening properties of this file) from that exe's code
[英]Opening a .exe file from configurable path
我想知道如何在 C# 中打開一個程序,在任何計算機上,我只能從它開始
Process.Start("C:\Users\\*name*\Desktop\MxMV2\MxMV2 EA\EA\bin\Debug\EA.exe");
但是我想把這個程序分享給我的朋友,他們沒有和我一樣的文件目錄。 那么我該怎么做呢?
您可以自由地不對桌面路徑進行硬編碼。
string desktoppath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
String path = @"MxMV2\MxMV2 EA\EA\bin\Debug\EA.exe";
Process.Start(desktoppath + @"\" + path);
這是你想要的嗎?
您可以為此目的使用SpecialFolder枚舉:
Process.Start($@"{Environment.GetFolderPath(Environment.SpecialFolder.Desktop)}\MxMV2\MxMV2 EA\EA\bin\Debug\EA.exe");
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.