date/time : 2005-12-03 01:04
computer name : BUZZ
user name : dpchato
operating system : Windows XP Service Pack 1 build 2600
system language : English
system up time : 11 minutes 26 seconds
program up time : 5 minutes 36 seconds
processor : Intel(R) Pentium(R) 4 CPU 2.00GHz
physical memory : 292/511 MB (free/total)
free disk space : (C:) 5.92 GB
display mode : 1024x768, 32 bit
process id : $f34
executable : sstogo.exe
exec. date/time : 2005-09-05 18:45
version : 8.3.1.45
madExcept version : 2.7c
exception class : EWriteError
exception message : Stream write error.
main thread ($f38):
004333d2 sstogo.exe Classes TStream.WriteBuffer
0043345b sstogo.exe Classes TStream.CopyFrom
005402f0 sstogo.exe Export 1145 TExportForm.CreateExecutable
And here's the code that was executing:
begin
MStream := TMemoryStream.create;
try
MFile := temp + FREE_STANDING_ARCHIVE;
MStream.LoadFromFile(MFile);
size := MStream.size;
OutputStream.Write(size,sizeof(size));
MStream.Seek(0,soFromBeginning);
>>> OutputStream.CopyFrom(MStream,MStream.size);
finally
MStream.Free;
end;
end;
The line with errors is where the error occurs. OutputSteam is
a TFileStream. And no, I don't recall why I load it to a
TMemoryStream.
Thanks,
Elliott
All this tells error tells us is that a write operation either failed
completely or wrote too few bytes. The former is most likely.
Unfortunately TFileStream does not allow you to find out what exactly
the error was. To get the proper exception you have to call the Windows
API correctly. Replace the marked line with this:
Win32Check(WriteFile(
(OutputStream as THandleStream).Handle,
MStream.Memory^, MStream.Size, BytesWritten, nil));
if BytesWritten < MStream.Size then
raise Exception.CreateFmt('Only wrote %d out of %d bytes',
[BytesWritten, MStream.Size]);
and add the variable BytesWritten of type LongWord.
Now you should get a proper exception. Please post that here.
> I have a user getting "Stream write error," and I'm stumped,
> since I don't know what the message might indicate, and it
> looks like he's not lacking for memory or disk space. Here's
>>>> OutputStream.CopyFrom(MStream,MStream.size);
> The line with errors is where the error occurs. OutputSteam is
> a TFileStream. And no, I don't recall why I load it to a
> TMemoryStream.
Perhaps because the input and output file are the same. If so there may be
some access issues in WinXP and later, even using a memory stream
intermediate.