Here is a snippit of the code...
private Hashtable readPDFile(string pdFile)
{
StreamReader reader = new StreamReader(File.OpenRead(pdFile));
Hashtable pdList = new Hashtable();
while (reader.ReadLine().Trim() != "NCE"){}
ArrayList entries = new ArrayList();
string entry;
entry = reader.ReadLine();
while(entry != "ZZZZ")
{
if(!entry.StartsWith("&"))
entries.Add(entry.Substring(0, 8));
entry = reader.ReadLine().Trim();
}
entries.Sort();
foreach(object o in entries)
{
string key = o.ToString().Substring(0, 7);
if(pdList.ContainsKey(key))
pdList[key] = Convert.ToInt32(pdList[key]) + 1;
else
pdList.Add(key, 1);
}
reader.Close();
return pdList;
}
Essentially, I am reading through a file which is seperated into
"chapters", which are denoted by headers. The section I want starts
with the header "NCE", so I am reading through the lines until I hit
that marker, and then read from the file until I hit the end of the
chapter, marked by "ZZZZ". From there, I parse through the list and
count the number of entries for each value, ignoring the final
character. In the example of the file that doesn't work, that is about
20,000 records, which this program can handle. The problem lies in
where the file itself contains more data further on in additional
chapters, which is padding the filesize to 10 mb. This code works with
smaller files with more records being read in (approx 30,000), so I
know it's the additional chapters that are the culprit.
And you are right, I am not getting a 404 error, but a "The page cannot
be displayed. The page you are looking for is currently unavailable.
The Web site might be experiencing technical difficulties, or you may
need to adjust your browser settings." error.
Hope this makes things clearer.
Thanks!
Adam Clauss wrote:
StreamReader itself should be quite capable of handling the file. How are
you parsing the file? Reading line by line? Reading the whole thing at
once? How are you then "separating" out the section you need?
Also, just to clarify - you say you are getting a 404 error. That is a
"Page Not Found" error, I don't believe a timeout would throw this...
--
Adam Clauss
"Matt Bailey" <ba*********@gmail.comwrote in message
news:11*********************@i42g2000cwa.googlegro ups.com...
I am writing an ASP page with a C# backend. This page uses a
StreamReader to input a file and pull out a specific section of the
text based on markers inside. While the code I have works, I get a 404
error on files larger than 10 mbs, which will be a common occurence. I
understand this might be a question better suited for an ASP forum, but
I was wondering if anyone out there knows of an alternative to the
StreamReader which will help me avoid this timout issue.
Thanks.