Why does this
//Load the Excel data
FileStream fs = new FileStream(edtFileName.Text, FileMode.Open,
FileAccess.Read);
int iLength = (int)fs.Length;
MemoryStream ms = new MemoryStream(iLength);
int iBytesToRead = 1024;
int iBytesRead = 0;
int iOffset = 0;
//do
//{
// iBytesRead = fs.Read(ms.GetBuffer(), iOffset, iBytesToRead);
// iOffset += iBytesRead;
//} while (iBytesRead > 0 && iOffset < iLength);
fs.Read(ms.GetBuffer(), iOffset, iLength); //this replaces the do-while loop (both yield same result)
c1XLBook.Load(ms, true); //<<<<-------- blows up here
result in this error?
"System.IO.IOException was unhandled by user code
Message="Failed to open storage file."
Source="C1.C1Excel.2"
StackTrace:
at C1.C1Excel.a0.b(Stream A_0)
at C1.C1Excel.C1XLBook.c(Stream A_0, Boolean A_1)
at C1.C1Excel.C1XLBook.Load(Stream stream, FileFormat format, Boolean fillSheets)
at C1.C1Excel.C1XLBook.Load(Stream stream, Boolean fillSheets)
at Tenneco.frmImportData.btnImport_Click(Object sender, EventArgs e)
My goal was to read the file into memory a chuck at a time and provide feedback during the read -- under the assumption that C1Excel.Load() would be quick since the data is in memory not in a file out on a network share. My assumption is based on the fact that Load() takes no time at all on my laptop where everything is run from the local hard drive.
Now that I've written this, I suppose I can try transferring the file from the network to the local hard drive... and then Load() the local copy.
What a pain.