473,326 Members | 2,048 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

CreateFile with FILE_FLAG_NO_BUFFERING "ala" .Net

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
4 17913
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

32
by: Marcus | last post by:
We all know that the "gets" function from the Standard C Library (which is part of the Standard C++ Library) is dangerous. It provides no bounds check, so it's easy to overwrite memory when using...
43
by: Zeng | last post by:
It's so messy w/o the "friend" relationship. Does anyone know why it was not supported in C#. It's almost about as bad as it doesn't support the inheritance hierarchy and method reference...
3
by: msnews.microsoft.com | last post by:
Hello All, In the "Find Dialog" (Ctrl-F) of the IDE there is an option called "Mark All". When I click "Mark All", this marks the occurences of my search text. How will I clear this mark? ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.