找到浏览器默认下载文件夹的路径
我们如何在c#/asp.net中找到浏览器默认下载文件夹的路径?
例如,我可以获取用户桌面的路径,例如:
Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
谢谢..
how can we find the path of browser default downloads folder in c# / asp.net?
For example I can get the path of user desktop like :
Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
Thanks..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您无法在网络应用程序中找到它。由用户决定使用哪个浏览器、如何配置浏览器以及默认保存下载文件的位置,您绝对无法干扰甚至无法从 Web 应用程序中了解他的选择。
You can't find that out in a web application. It's up to the user to decide which browser to use and how to configure it and where to save downloaded files by default and you have absolutely no way of interfering or even knowing his choices from a web application.
首先,在
Environment.SpecialFolder
上查看 MSDN,没有下载文件夹,原因是每个浏览器的下载文件夹都不同。http://msdn.microsoft.com/en-us/library /system.environment.specialfolder.aspx
与asp.net无关,如果你从服务器端查看它,你只是得到一个不知道在哪里的目录,这意味着这与Web应用程序无关在泳池下面运行的。
您可以做什么
您可以使用 HttpRuntime.AppDomainAppPath 并使用它来了解您的网站所在的位置,并放置一个“下载”目录并使用此完整路径:
用于下载/上传文件。
First of all looking at MSDN on
Environment.SpecialFolder
there is no download folder, and the reason is that this is different for every browser.http://msdn.microsoft.com/en-us/library/system.environment.specialfolder.aspx
And there have nothing to do with asp.net, if you look it from the server side you just get a directory on nowhere, meaning that this have nothing to do with the web application that run under the pool.
What you can do
You can use the HttpRuntime.AppDomainAppPath and use it to know where your site lives, and there place a "download" directory and use this full path:
for download/upload files.