在C#sharp中选择一个文件 [英] select a file in C#sharp

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

问题描述



我使用System.Diagnostics.Process.Start(foldername)在c#中打开一个文件夹.

打开目录后,如何使用c#代码在该文件夹中选择文件?
例如. Internet下载管理器,当您单击打开目录的打开文件夹并自动选择下载的文件时,该怎么办?

Hi,

I use System.Diagnostics.Process.Start(foldername) to open a folder in c#.

How can I select a file in that folder with c# code when the directory was opened?
Eg. Internet download manager that when you click on open folder that open directtory and automatically select your downloaded file, how can I do that?

推荐答案

为此使用FolderBrowserDialog组件:请参阅 http://social.msdn.microsoft.com /forums/zh-CN/csharpgeneral/thread/a9d6548b-8197-446f-a50a-35ca220035c1 [
Use the FolderBrowserDialog component for this: see http://social.msdn.microsoft.com/forums/en-US/csharpgeneral/thread/a9d6548b-8197-446f-a50a-35ca220035c1[^]


如果我正确理解了您想要实现的目标类似于Visual Studios的打开包含文件夹"功能.我通常通过使用资源管理器/select选项来做到这一点.

If I understand you correctly you want to achieve something like Visual Studios ''Open containing folder'' feature. I usually do that by using explorers /select option.

Process.Start("explorer.exe", string.Format("/select,\"{0}\"", <filename>));



另请参见
http://support.microsoft.com/kb/314853 [



see also http://support.microsoft.com/kb/314853[^] for more information about the select option of explorer.


这篇关于在C#sharp中选择一个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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