我正在尝试打开我的系统的本地光盘D路径中的excel,因为我已经设置了这个波纹管字符串,但它不能在c#.net
中工作string strScript = "<script language=JavaScript>window.open('file://D:/Ajman/FrameworkWebUI/Temp/ExcelFileName.xls',null,'width=1,height=1,toolbar=no,top=300,left=700,right=1, scrollbars=no,locaton=yes,resizable=1');</script>";
答案 0 :(得分:0)
如果文件位于服务器位置:
您应该使用基于网络的地址文件而不是文件系统模式
e.g。 :
\\myserver\files\aaa.jpg
答案 1 :(得分:0)
答案 2 :(得分:0)
如果您使用C#为什么不使用它来获取文件,为什么要使用javascript? 你可以这样做:
string filepath = Server.MapPath(name of the file);
//The file location must be accessible to the website
然后您可以使用File
或FileInfo
类来获取文件
FileInfo file = new FileInfo(filepath);
//OR
File.Open(filepath, FileMode.Open))
答案 3 :(得分:0)
您只能访问IE上的文件位置。如果您使用任何其他浏览器,它将无法正常工作。我认为Firefox有一个注册表攻击,但为了在所有浏览器中保持一致,您可能希望在服务器端读取文件的内容并使用回发或AJAX显示它。