422,922 Members | 2,127 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 422,922 IT Pros & Developers. It's quick & easy.

CreateFile with FILE_FLAG_NO_BUFFERING "ala" .Net

P: n/a
Hi,

How can I open a file with the FILE_FLAG_NO_BUFFERING
using .net just like in the win32 days ?

Nov 16 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
I guess you need to open the file with no system caching. Yes .Net supports
this.. Have a look at System.Xml name space for XML files.. System.IO.File
for all the files..

Nirosh.

<cr************@hotmail.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
Hi,

How can I open a file with the FILE_FLAG_NO_BUFFERING
using .net just like in the win32 days ?

Nov 16 '05 #2

P: n/a
All file IO API's in the FCL are buffered, you need to PInvoke CreateFile
(kernel32) and specify the FILE_FLAG_NO_BUFFERING, the returned handle can
be wrapped by a FileStream class.
Beware that the request buffer must be sector size aligned and the request
size must be a multiple of a sector size.

Willy.

<cr************@hotmail.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
Hi,

How can I open a file with the FILE_FLAG_NO_BUFFERING
using .net just like in the win32 days ?

Nov 16 '05 #3

P: n/a
Hi, Willy :

Thanks for the advise, I didn't realize there's a constructor that
accept the file handle as parameter, so, this should work.
The only bad thing is that this puts my application in non-safe mode,
which was I requirement I have. I'll try to circunvent this in another
way.

Regards,


Willy Denoyette [MVP] wrote:
All file IO API's in the FCL are buffered, you need to PInvoke CreateFile (kernel32) and specify the FILE_FLAG_NO_BUFFERING, the returned handle can be wrapped by a FileStream class.
Beware that the request buffer must be sector size aligned and the request size must be a multiple of a sector size.

Willy.

<cr************@hotmail.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
Hi,

How can I open a file with the FILE_FLAG_NO_BUFFERING
using .net just like in the win32 days ?


Nov 16 '05 #4

P: n/a
What do you mean with "unsafe" mode? There is nothing unsafe in using
DllImport to declare and use Win32 API's.

Willy.

<cr************@hotmail.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
Hi, Willy :

Thanks for the advise, I didn't realize there's a constructor that
accept the file handle as parameter, so, this should work.
The only bad thing is that this puts my application in non-safe mode,
which was I requirement I have. I'll try to circunvent this in another
way.

Regards,


Willy Denoyette [MVP] wrote:
All file IO API's in the FCL are buffered, you need to PInvoke

CreateFile
(kernel32) and specify the FILE_FLAG_NO_BUFFERING, the returned

handle can
be wrapped by a FileStream class.
Beware that the request buffer must be sector size aligned and the

request
size must be a multiple of a sector size.

Willy.

<cr************@hotmail.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
> Hi,
>
> How can I open a file with the FILE_FLAG_NO_BUFFERING
> using .net just like in the win32 days ?
>

Nov 16 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.