Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

C# Programming

EOF Occurs Early


I have an interesting problem with file IO, maybe even a bug in the CLR.

I call a method that uses an XmlReader to loop through 4 MB XML files and
store the text in a database. I select the files in a file select dialog and
loop through the filename array, calling the XmlReader method each time.

If I input one file, everything works properly. If I input several files,
the first file is not read completely. The rest are then processed
correctly. It doesn't matter which file is the first file selected, it
always results in incomplete data from that file. In fact, it always drops
off at the same record each time, about a quarter way through the file.

I checked with the debugger, and when the file hits the record where it
drops out, the XmlReader reports end of file.

Has anyone heard of a similar problem as this? Any ideas how I might fix or
workaround the problem?

I tried adding a FileStream to the XmlReader but it didn't help.

--
Regards,

Fred Chateau
http://hotelmotelnow.com

I got some more information to go with this.

You can select four files and all files are processed correctly. Seven or
more files causes the first one to drop out early. Does this make sense to
anyone because it doesn't make sense to me? The files are being processed
one at a time, I think. It's just the filenames that are held in an array
until the method is called.

--
Regards,

Fred Chateau
http://hotelmotelnow.com

"Fred Chateau" <webmas@hotelmotelnow.com> wrote in message

news:%235LCZF9pHHA.1244@TK2MSFTNGP04.phx.gbl...

I added back the FileStream in order to see more information about the file
in the debugger. When five or more files are selected, the first file shows
a different file size than it actually is.

--
Regards,

Fred Chateau
http://hotelmotelnow.com

"Fred Chateau" <webmas@hotelmotelnow.com> wrote in message

news:eW8r3S$pHHA.2288@TK2MSFTNGP06.phx.gbl...

Fred Chateau <webmas@hotelmotelnow.com> wrote:
> I added back the FileStream in order to see more information about the file
> in the debugger. When five or more files are selected, the first file shows
> a different file size than it actually is.

Without seeing any code, it's going to be virtually impossible to get
any further on this.

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

--
Jon Skeet - <s@pobox.com>
http://www.pobox.com/~skeet   Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

-----------------------------------------------Reply-----------------------------------------------

I found it. Apparently one of the files (the last file) is shorter than the
rest. What I discovered is that when you load multiple files into the
OpenFileDialog, no matter what order you select them, apparently the dialog
loads them from the smallest file to the largest.

Even though the standard filename sorting order is different, it doesn't
seem to make any difference. In this case, the file was named xxx014.xml and
it loaded before xxx001.xml.

--
Regards,

Fred Chateau
http://hotelmotelnow.com

"Jon Skeet [C# MVP]" <s@pobox.com> wrote in message
news:MPG.20d067b220959e271bc@msnews.microsoft.com...

Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc