For Programmers: Free Programming Magazines  


Home > Archive > VC Language > June 2005 > WriteFile reports x bytes written, but file does not grow









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author WriteFile reports x bytes written, but file does not grow
Rob Vermeulen

2005-06-03, 4:02 pm

Folks,

I'm not quite sure if this is the correct newsgroup to post it, but I'm sure
there are experts here that might have an answer to my question.
I have developed a .net isapi DLL (Web Service) that uses a COM object to
cut and merge WAV files.
Now, the Web Service and the COM object work fine on my XP machine, writing
the file as it should.

However, when I run the complete system on a Win2000 machine, my writefile
in the COM object acts strangely.
It should write some buffer to a file, and the BytesWritten returns exactly
the number of bytes that need to be written, but my file does not grow. I'm
offering a total amount of 20 MB to write (in 4096 kB buffers) but the file
stays 1 kB. This 1 kB is from a previous WriteFile action that writes a WAV
header to the file.
So, after writing the wave header, every call to writefile does not result
in file growth.

Does anyone have similar experience or has seen this kind of behavior
before?

I appreciate any response.

Thanks in advance!

Rob Vermeulen.




Jochen Kalmbach [MVP]

2005-06-03, 4:02 pm

Hi Rob!
> However, when I run the complete system on a Win2000 machine, my writefile
> in the COM object acts strangely.
> It should write some buffer to a file, and the BytesWritten returns exactly
> the number of bytes that need to be written, but my file does not grow. I'm
> offering a total amount of 20 MB to write (in 4096 kB buffers) but the file
> stays 1 kB. This 1 kB is from a previous WriteFile action that writes a WAV
> header to the file.
> So, after writing the wave header, every call to writefile does not result
> in file growth.
>
> Does anyone have similar experience or has seen this kind of behavior
> before?


The OS can (and will) buffer your output. The file is written if you
close it or call FlushFileBuffers.

--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
James Brown

2005-06-03, 4:02 pm

Are you determining the file length from explorer,
or using GetFileSize API? Maybe explorer doesn't notice
writes/change in size until file is closed...?

James

--
www.catch22.net
Free win32 software, sourcecode and tutorials


"Rob Vermeulen" <rvermeulen@nospam-arbor-audio-spamless.com> wrote in
message news:11a0mqp67tpq34e@corp.supernews.com...
> Folks,
>
> I'm not quite sure if this is the correct newsgroup to post it, but I'm
> sure there are experts here that might have an answer to my question.
> I have developed a .net isapi DLL (Web Service) that uses a COM object to
> cut and merge WAV files.
> Now, the Web Service and the COM object work fine on my XP machine,
> writing the file as it should.
>
> However, when I run the complete system on a Win2000 machine, my writefile
> in the COM object acts strangely.
> It should write some buffer to a file, and the BytesWritten returns
> exactly the number of bytes that need to be written, but my file does not
> grow. I'm offering a total amount of 20 MB to write (in 4096 kB buffers)
> but the file stays 1 kB. This 1 kB is from a previous WriteFile action
> that writes a WAV header to the file.
> So, after writing the wave header, every call to writefile does not result
> in file growth.
>
> Does anyone have similar experience or has seen this kind of behavior
> before?
>
> I appreciate any response.
>
> Thanks in advance!
>
> Rob Vermeulen.
>
>
>
>



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com