Hi,

I use an IO.Filestream to write a single byte close to the end of a huge
file (120 GB) by setting the Position property and calling the WriteByte
method. This takes 40 minutes because all the bytes before the byte
to be written seems to be written. But I only want to write a single byte
into the file! How can this be done?


Armin

Re: IO.Filestream: write single byte (.Net 1.1) by Jon

Jon
Sun Mar 25 14:07:57 CDT 2007

Armin Zingler <az.nospam@freenet.de> wrote:
> I use an IO.Filestream to write a single byte close to the end of a huge
> file (120 GB) by setting the Position property and calling the WriteByte
> method. This takes 40 minutes because all the bytes before the byte
> to be written seems to be written. But I only want to write a single byte
> into the file! How can this be done?

This sounds mad - it certainly shouldn't do that. Using the Position
property shouldn't write anything.

Is this a local file, or on a network?

--
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

Re: IO.Filestream: write single byte (.Net 1.1) by Armin

Armin
Sun Mar 25 14:54:11 CDT 2007

"Jon Skeet [C# MVP]" <skeet@pobox.com> schrieb
> Armin Zingler <az.nospam@freenet.de> wrote:
> > I use an IO.Filestream to write a single byte close to the end of
> > a huge file (120 GB) by setting the Position property and calling
> > the WriteByte method. This takes 40 minutes because all the bytes
> > before the byte to be written seems to be written. But I only want
> > to write a single byte into the file! How can this be done?
>
> This sounds mad - it certainly shouldn't do that. Using the Position
> property shouldn't write anything.
>
> Is this a local file, or on a network?


A local file. Meanwhile I got a hint in the German framework group, pointing
me to
http://groups.google.com/group/microsoft.public.win2000.file_system/msg/5d3cbefd8a0de8bf
and to the API function SetFileValidData. Seems to be the function I'm
looking for. Though, I'm still trying to find out how to obtain the required
privilege (SE_MANAGE_VOLUME_NAME) to use this function.


Armin


Re: IO.Filestream: write single byte (.Net 1.1) by Armin

Armin
Sun Mar 25 18:17:54 CDT 2007

"Armin Zingler" <az.nospam@freenet.de> schrieb
> "Jon Skeet [C# MVP]" <skeet@pobox.com> schrieb
> > Armin Zingler <az.nospam@freenet.de> wrote:
> > > I use an IO.Filestream to write a single byte close to the end
> > > of a huge file (120 GB) by setting the Position property and
> > > calling the WriteByte method. This takes 40 minutes because all
> > > the bytes before the byte to be written seems to be written. But
> > > I only want to write a single byte into the file! How can this
> > > be done?
> >
> > This sounds mad - it certainly shouldn't do that. Using the
> > Position property shouldn't write anything.
> >
> > Is this a local file, or on a network?
>
>
> A local file. Meanwhile I got a hint in the German framework group,
> pointing me to
> http://groups.google.com/group/microsoft.public.win2000.file_system/msg/5d3cbefd8a0de8bf
> and to the API function SetFileValidData. Seems to be the function
> I'm looking for. Though, I'm still trying to find out how to obtain
> the required privilege (SE_MANAGE_VOLUME_NAME) to use this function.


I wasn't successfull. SetFileValidData does not work. It always returns
False and I still get Win32 error 1314 ("A required privilege is not held by
the client."). But I am administrator and I do have this privilege and I do
have all access rights on the file. I don't know what to do anymore.
I'll also ask in a Win32 group about the SetFileValidData, but I'd also be
happy if you might have a hint, too.


Armin