Re: Only writing 1 byte to a file stream on one pc in office
- From: "Ben Voigt [C++ MVP]" <rbv@xxxxxxxxxxxxx>
- Date: Mon, 23 Jul 2007 12:21:54 -0500
"ModelBuilder" <ModelBuilder@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:E50EFD03-BB0C-4B24-A398-A82847048FF3@xxxxxxxxxxxxxxxx
In this instance though you are not catching and logging anything. You
are
just ignoring any issues and closing the open stream.
???
The OP has a finally block, not catch (...), so he isn't ignoring anything.
His application-level exception handler will log any exception... but the
whole call stack should be checked for silent discards.
"Claire" wrote:
Hi,
I read image data from a database and cache them locally to file via a
filestream.
One of my users commented that his application isnt showing images. On
checking his file cache I found that most of the files were only 1 byte
in
length. I deleted all the files, re-ran the application and again the
files
were truncated after 1 byte.
I protect my code with try/catch and log all exceptions to the windows
event
log and to a log file. There were no exceptions listed.
We're on a domain.
The code works fine on other pcs. I can't work out why only one byte, or
why
there's no error
// read in the record with binary reader
tableImages datarecord = new tableImages(reader);
// write the image to file
FileStream fs = new FileStream(ImageLocation, FileMode.Create,
FileAccess.Write, FileShare.None);
try
{
// Assign the image bytes to variable
byte[] data = datarecord.FileData;
fs.Write(data, 0, data.Length);
fs.Flush();
}
finally
{
fs.Close();
}// finally
.
- References:
- Prev by Date: Re: Only writing 1 byte to a file stream on one pc in office
- Next by Date: Re: Replacement for DataTable
- Previous by thread: Re: Only writing 1 byte to a file stream on one pc in office
- Next by thread: how to validate QueryString?
- Index(es):
Relevant Pages
|