I have an ASP.NET site in which I need to binary-write the contents of files to the users' browsers rather than linking to the files via the use of URLs. The following example shows how to open a file on a local drive using its physical path and then write the binary contents of the file to the browser:
VB Code:
Response.ContentType = "Application/pdf" Response.WriteFile("C:\Test\Test.pdf") Response.End()
The above code works fine, but if I put the file on a mapped drive (e.g. "G:\Test\Test.pdf"), I get an error which says "System.IO.DirectoryNotFoundException: Could not find a part of the path "G:\Test\Test.pdf".
If I use the full path to the file, which is on another server (e.g. "\\ServerName\cdrive\Test\Test.pdf"), I get the following error message: "System.IO.IOException: Logon failure: unknown user name or bad password"
I am able to access the file via Windows Explorer. I believe the problem may have something to do with authentication. Can anyone help me with this?
Thanks.




Reply With Quote