如何在C#中生成文件的通用路径 [英] How to generate a generic path of a file in C#

查看:100
本文介绍了如何在C#中生成文件的通用路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好!!!我的名字是Hamza Chaudhry,我现在遇到了问题...

i我正在制作一个软件来打开一个exe文件名Rufus.exe我不是伟大的开发者我尝试了很多帮助内容但他们都没有工作。我想要一个代码,我将写,我的exe文件打开,它将在其他计算机上打开.....我需要帮助请帮助我,我已经尝试过这段代码

Hello !!! My name is Hamza Chaudhry and i am now in a problem...
i am making a software to open a exe file name "Rufus.exe" i am not the great developer i have tried many help contents but they all are not working. i want a code that i will write and my exe file opens and it will open on other computers also..... I need help please help me i have tried this code





private void button1_Click(object sender, EventArgs e)

    {
        Process p = new Process();
        p.StartInfo.FileName = @"E:\Hamza Development Tools don't Touch This Folder\WindowsFormsApplication6\WindowsFormsApplication6\Rufus.exe";
        p.Start();
        //add reference System.IO or use System.IO.Path and it is "Path"
    }



请帮助我如何制作我的软件.........


Please help how can i make my software.........

推荐答案

保持exe在你拥有你开发的exe的同一路径中打开。



使用Application.StartUpPath + exename



希望这会有所帮助。
Keep the exe to be opened in the same path where you have the exe you have developed.

Use "Application.StartUpPath" + exename

Hope this helps.






你可以尝试这样,



Hi,

You can try like this,

try
{
     string path = @"E:\Hamza Development Tools don't Touch This Folder\WindowsFormsApplication6\WindowsFormsApplication6\Rufus.exe";
     ProcessStartInfo pinfo = new ProcessStartInfo(path);
     Process.Start(pinfo);
}
catch(Exception exc) { }







希望它能运作。




Hope it will work.


试试:

Process.Start(@E:\ Hamza开发工具不要触摸此文件夹\ WindowsFormsApplication6 \ WindowsFormsApplication6 \ Rufus.exe);
Try:
Process.Start(@"E:\Hamza Development Tools don't Touch This Folder\WindowsFormsApplication6\WindowsFormsApplication6\Rufus.exe");


这篇关于如何在C#中生成文件的通用路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆