Solution:
It turns out I wasn't checking the path that it was looking up, quite silly of me. Once I tracked that problem down and corrected the offending path, the reading worked just fine. Still baffled at the MSSQL issue, since the articles average less than 10 000 bytes.
Clarification:
I am unsure if some of you are under the impression that the file I am trying to read is on my local machine. It resides on the web, on the same server as the script that is accessing it. Just in a different directory.
I wrote an online help desk application that includes articles. One problem I have run into
is some of the articles are too long, and get truncated when I put them into my MSSQL database. I tried using TEXT
and VARCHAR(MAX)
as the data type, but it would still get truncated.
So I decided that I would put the articles that are too long into a text file, and have my application read the text file from there. I got this code working in my development environment, but it does not work live:
Dim output As String = String.Empty
Try
Dim theArticle As gsClassroom = classArticles(iterate)
If theArticle.Body.StartsWith("/docs/") Then
Dim oReader As IO.StreamReader = Nothing
Try
oReader = New IO.StreamReader(Server.MapPath(String.Format("/dev{0}", theArticle.Body)))
Catch ex As Exception
output = String.Format("{0}<br /><br />{1}", ex.Message, "internal")
Finally
oReader.Close()
oReader.Dispose()
oReader = Nothing
End Try
Else
output = theArticle.Body
End If
Catch ex As Exception
output = String.Format("{0}<br /><br />{1}", ex.Message, "external")
End Try
Response.Output.WriteLine(output)
At first, I thought it was because I did not change the /dev
path prefix to /hlpdsk
. But even after I changed it, it bombed out. What am I doing wrong?