我正在编写一个 ASP 应用程序,它将通过浏览器向客户端提供文件。这些文件位于通过 UNC 路径 (\server\some\path) 运行 IIS 的计算机上可用的文件服务器上。
我想使用类似下面的代码来提供文件。为运行 IIS 的机器提供本地文件可以很好地使用这种方法,我的麻烦是能够从 UNC 映射共享提供文件:
//Set the appropriate ContentType.
Response.ContentType = "Application/pdf";
//Get the physical path to the file.
string FilePath = MapPath("acrobat.pdf");
//Write the file directly to the HTTP content output stream.
Response.WriteFile(FilePath);
Response.End();
我的问题是如何为文件名指定 UNC 路径。此外,要访问文件共享,我需要使用特定的用户名/密码进行连接。
我将不胜感激有关如何实现这一目标的一些指示(使用上述方法或通过其他方式)。