我们如何在C#中打开已保存的文件夹? [英] How can we open a saved files folder in C#

查看:95
本文介绍了我们如何在C#中打开已保存的文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





当我们点击该按钮时我会有一个按钮它会上传文件,上传文件到某个文件夹后我需要查看文件夹所在的位置文件正在运行时上传...我使用openfiledialog但是将默认路径作为prject文件夹



我尝试过:





I have one button when we click on that button it will upload the files, after uploading files to certain folder i need to see the folder where files are being uploaded with in the run time...i uused openfiledialog but is taking default path as prject folder

What I have tried:

OpenFileDialog ofd = new OpenFileDialog();
			string path= SourceFilePath;
			  if (ofd.ShowDialog() == DialogResult.OK)      
			    {                  			              
			        path = System.IO.Path.GetDirectoryName(ofd.FileName);     
			     }     			       
				} else {		

推荐答案

您对上传文件的评论意味着这是一个基于网络的解决方案,您无法在网站上使用OpenFileDialog - C#代码在服务器而不是客户端运行,因此所有消息框都将在用户无法看到它们的服务器上打开。它似乎只在开发中工作,因为服务器和客户端是相同的物理计算机。



不要花时间尝试修复文件夹:这种方法不会在生产中工作。
Your comment of "uploading files" implies this is a web based solution, and you can't use OpenFileDialog at all on websites - C# code runs at the Server, not the Client, so all message boxes will open at the Server where the user can't see them. It only appears to work in development because the Server and the Client are the same physical computer.

Don't spend time trying to fix the folder: this approach will not work at all in production.


这篇关于我们如何在C#中打开已保存的文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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