简体   繁体   English

如何在ASP.NET的客户端读取/写入文件

[英]How to read/write file on client side in ASP.NET

如何从asp.net中的本地文件系统(客户端)读取文件,是否有任何ActiveX要求执行此操作,或者可以不使用它来完成

It cannot be done without extra help like an ActiveX, but I'm not aware of any ready-made solutions. 没有ActiveX之类的额外帮助就无法完成,但是我不知道有任何现成的解决方案。 Why do you want to read a local file? 为什么要读取本地文件? Most users will not like this approach... 大多数用户不会喜欢这种方法...

What are you really trying to do ?? 您真正想做什么? Isn't there another way (eg user uploading the file to your ASP.NET site) to achieve the result you want?? 有没有其他方法(例如,用户将文件上传到您的ASP.NET站点)来获得所需的结果?

Marc

you can use Javascript and this can be done by using FileSystemObject object 您可以使用Javascript,这可以通过使用FileSystemObject对象来完成

check the following link: 检查以下链接:

File Handling at Client Side using Javascript 使用Javascript在客户端进行文件处理

Note: 注意:

This object is part of Microsoft ' Scripting Engine, and thus this column is applicable only to Microsoft Windows operating systems . 该对象是Microsoft脚本引擎的一部分,因此,此列仅适用于Microsoft Windows操作系统

As Marc Said, ASP.net can't do it. 正如Marc说的那样,ASP.net无法做到。

There are a few options 有几种选择

  • Provide a file upload mechanism (most common, easiest) 提供文件上传机制(最常见,最简单)
  • Use ActiveX 使用ActiveX
  • Use Silverlight, at least with silverlight you can write in managed code and access the client(instructions for file open and file save ) 使用Silverlight,至少使用Silverlight可以编写托管代码并访问客户端( 打开 文件保存 文件的说明)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM