I have an ASP.Net site that includes a folder named "files" as a subdirectory of the site. I have a help page set up with links that are set to "~/files/help1.doc", "~/files/help2.doc", etc... These all work great.
I have another section of the site where the user clicks a button and I try to read one of the Word docs into a filestream, convert it to Bytes, and save it to a database.
The line to read the file into the filestream is:
Dim fs As New FileStream(Server.MapPath("~/files/help1.doc"), FileMode.Open)
And it errors out there every time saying access to that path is denied. I can click the links all day long and read the Word docs, but when I try to read it using the line above it can't.
Why can I access the documents through a straight link, but I can't read that same document from that same location using a File Stream?
Is there some other method I can use to read the file into a file stream or memory stream?
It seems like if it were a permissions issue I wouldn't be able to access the Docs through any means. The fact that I do have permission to pop the Doc open in my browser window seems to suggest I have enough permission to the "files" folder to read things out of it.