如何获取当前目录路径c#winfows应用程序 [英] How to get the current directory path c# winfows application

查看:85
本文介绍了如何获取当前目录路径c#winfows应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个Windows窗体应用程序,我想将文件保存在文件文件夹中。如何获取当前路径?

I created a windows form application, I want to save a file in folder "Files". How can I get the current path ?

推荐答案

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



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,


这篇关于如何获取当前目录路径c#winfows应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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