且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何获取当前目录路径c#winfows应用程序

更新时间:2023-02-21 17:32:46

如果您指的是应用程序启动的路径,请使用:



If you mean the path where your app got started then use:

Application.StartupPath







由于进一步编辑信息:






EDIT due to further information:

OpenFileDialog ofd = new OpenFileDialog();

//Change this to your needs
ofd.Multiselect = true;

if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
   //SingleSelect
   //string fullPath = ofd.FileName;

   //MulitSelect
   if (ofd.FileNames.Length > 0)
   {
     string[] fullPaths = ofd.FileNames;
   }
}


Environment.CurrentDirectory来检索当前目录



谢谢,
Environment.CurrentDirectory to retreive the current directory

Thanks,