C#获取在Windows资源管理器中选择的文件路径 [英] C# get a file path which is selected in the Windows Explorer

查看:545
本文介绍了C#获取在Windows资源管理器中选择的文件路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿伙计们,

我有一个项目,我想在我的Windows资源管理器中选择一个文件,并在C#中使用该文件的路径。

是有机会获得这条路吗?

Hey guys,
I've got a Project where I want to select a file in my Windows Explorer and use the path of this file in C#.
Is there any opportunity to get this path?

推荐答案

System.Windows.Forms.OpenFileDialog ofd;
if (ofd.ShowDialog() == DialogResult.OK)
{
        string File = ofd.FileName;
}





[补充]

根据您的要求添加参考:

参见帮助文章(向下滚动一点,你会看到)

它会帮助你添加参考,

[/补充]



干杯,

Edo



[supplemental]
As per your request with adding the reference:
See help article (scroll down a little bit, you'll see)
it will help you with adding the reference,
[/supplemental]

Cheers,
Edo


首先非常感谢:)

但我需要任何组装吗?因为我的编译器给了我一个错误。
First thanks a lot :)
But do I need any assembly for that? because my compiler give me an error.


这篇关于C#获取在Windows资源管理器中选择的文件路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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