Re: Only writing 1 byte to a file stream on one pc in office

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance




"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






.



Relevant Pages

  • Re: Overriden method doesnt throw Exception, super may.
    ... >> haven't been ignoring you, I've actually been trying to understand the ... idea of ignoring the exception, and then try to blast me for it? ... is, as has been pointed out, the exception is NEVER thrown because the ... Converting to a runtime exception is just as bad an idea here as ignoring ...
    (comp.lang.java.programmer)
  • Re: FileSystemWatcher and Getting Access to a file
    ... the file until the exception goes away. ... and ignoring a particular exception. ... "Lebrun Thomas" wrote in message ... >> elegant solution to this problem rather than just "trying to continually ...
    (microsoft.public.dotnet.framework)
  • Re: Strange Audio Problem
    ... >Perhaps it is throwing an exception the code is ignoring. ... Exception and stacktraces them all just to be sure that it isn't the ... Could it be something else than an infinite loop? ... And the server and the test-program both runs on the same machine under ...
    (comp.lang.java.programmer)
  • Re: Highway code section 114 (dazzle from vehicle lighting)
    ... handbrake MUST be applied EVERY time a car is staionary?..no matter ... exception to the rule then you will feel justified in ignoring it & ...
    (uk.rec.driving)
  • Re: Problem with FileStream - FileNotFoundException
    ... impersonation must be turned off. ... I have the following problem with FileStream. ... User on which application is running has full permision to the destination folder. ... I've cheked other constructors of the FileStream class and the same exception is thrown. ...
    (microsoft.public.dotnet.framework.aspnet)