在 C# VS2005 中浏览文件夹
我的 VS2005 上有一个使用 C# 的文件格式转换器。现在我的目标路径是硬编码的,我想让用户能够浏览到存储输出文件的路径。
我用google搜索了一下,发现可以在VS2005工具箱的Dialogs下使用OpenFileDialog控件。但我在 VS2005 中找不到该控件。
我不知道是否可以保存上传文件的文件路径,但我可以保存用户浏览的文件的文件名和扩展名。 例如 Grep 文件名: string strFileName = Server.HtmlEncode(TextFile.FileName); Grep 文件扩展名: string strExtension = Path.GetExtension(strFileName);
我想问两个问题:
- OpenFileDialog 是否有替代方案可以用来浏览文件夹?
- 是否有一个语句能够像我对文件名和文件扩展名所做的那样 grep 文件的文件路径?
谢谢
我可以使用任何替代方案吗?
I have a file format converter on my VS2005 using C#. Now my destination path is hard coded, and I would like to make it such that the user is able to browse for a path to store the output file.
I have googled and saw that I can use OpenFileDialog control in VS2005 toolbox under Dialogs. But I am not able to find that control in my VS2005.
I do not know if it is possible to save the filepath of the uploaded file, but I am able to save the file name and extension of the file that the user browses for.
E.g. Grep file name: string strFileName = Server.HtmlEncode(TextFile.FileName);
Grep file extension: string strExtension = Path.GetExtension(strFileName);
I would like to ask 2 questions:
- Is there an alternative for OpenFileDialog which I can use to browse for folders?
- Is there a statement which is able to grep the filepath of the file like what I have did to grep the filename and file extension?
Thank You
Any alternatives which I can use?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您正在寻找
FolderBrowserDialog
类。如果您使用的是 WPF,则需要添加对 System.Windows.Forms 的引用,因为 WPF 没有自己的此类版本。
如果您使用 ASP.Net,这是完全不可能的,就像使用硬编码路径一样;您需要将该文件作为下载提供。
您还在寻找
Path.GetDirectoryName
。You're looking for the
FolderBrowserDialog
class.If you're using WPF, you'll need to add a reference to System.Windows.Forms, since WPF doesn't have its own version of this class.
If you're using ASP.Net, this is totally impossible, as is using a hard-coded path; you need to serve the file as a download.
You're also looking for
Path.GetDirectoryName
.