如何使用C#和ASP.Net选择文件夹路径? [英] How to choose Folder Path using C# and ASP.Net?

查看:322
本文介绍了如何使用C#和ASP.Net选择文件夹路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



如何选择文件夹位置然后使用文件上传控件从该文件夹中获取所有文件

没有选择文件从文件上传控制,

先谢谢。

解决方案

你不能,不能从服务器。或者至少,你不能在99.99%的情况下。



服务器无法访问客户端文件系统,或者甚至不知道客户端是否有文件系统。

FileUpload控件开始浏览的文件夹完全取决于浏览器 - 你可以控制它。


你需要理解这个概念。 br />

想想



您浏览某个网站,然后在您不知情的情况下从系统中获取文件并在服务器上对其执行某些操作。然后它可以对该文件执行任何操作,您无法控制它。

为什么会发生这种情况?



如果可能的话那就是黑客攻击。这就是为什么,这是不可能的。浏览器的安全功能不允许您在未经他/她许可的情况下从客户的系统中选择任何内容,这应该是理想的行为。否则每个人都会害怕访问网站。

那么,现在该怎么办?



不要这样做。请求用户的许可并获取文件。 :)

Hi All,

How to choose a Folder Location then get all files from that Folder using file upload control
without select file from file upload Control,
Thanks in Advance.

解决方案

You can't, not from the server. Or at least, you can't in 99.99% of circumstances.

The server has no access to the client file system, or to even know if the client has a file system.
The folder the FileUpload control starts browsing in is completely browser dependent - you can;t control it.


You need to understand the concept.

Think


You browse some website, then without your knowledge it takes a file from your system and do some operations on it on Server. It can then do anything with that file, you don't have any control over it.

Why this happens?


If this is possible, then it is hack. That's why, it is not possible. Browser's security feature don't allow you to select anything from Client's system, without his/her permission and that should be the ideal behaviour. Otherwise everybody will scare to visit websites.

So, what to do now?


Don't do this. Ask for user's permission and get the file. :)


这篇关于如何使用C#和ASP.Net选择文件夹路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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