My website is published under c:\inetpub\wwwroot folder and I have some large text files on D: drive that I need to access. Let's say the exact location is D:\Test\test.txt. When my website runs it keeps failing on the File.Exists()
check. I have tried the following but none worked:
- Created virtual dir from IIS to point to this folder and used
Server.MapPath
in code - Gave Network Service read access to this Test folder
- Shared the folder with Network Service and in the website reference the UNC path
All of the above failed and the site still says the file doesn't exist, but it's there. Any ideas?
EDIT: Below are several attempts that I placed in Page_Load which failed:
if (File.Exists(@"D:\Test\test.txt"))
{ ... }
if (File.Exists(Server.MapPath("TestVirtualDir/test.txt")))
{ ... }