473,513 Members | 2,356 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 17928
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
3756
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
2796
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
1536
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
7267
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7391
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7553
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7120
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
5100
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4754
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1609
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
809
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
466
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.