I want to do something like

where:
m_Device(_T(\\\\.\\PHYSICALDRIVE1) to read drive 1

I then want to read the physical device till the end and save it in a disk
file. Does anyone have an example of doing this in c#. Below are the
pertinate lines from c++. The framework does not appear to support physical
access.

DeviceHandle = CreateFile(m_Device, GENERIC_READ,FILE_SHARE_READ, NULL,
OPEN_EXISTING, FILE_FLAG_NO_BUFFERING, NULL);

then in a loop

rc = ReadFile(DeviceHandle, buffer, sizeof(buffer), &BytesRead, NULL);



__





Jim

I need to do physocal disk reads by Muhammad

Muhammad
Wed Dec 17 16:16:42 CST 2003

I am not sure, If I understood the problem correctly. But
if you want to read a file, the here is the code sample.

string path = @"c:\temp\MyTest.txt";

// Open the file to read from.
using (StreamReader sr = File.OpenText(path))
{
string s = "";
while ((s = sr.ReadLine()) != null)
{
Console.WriteLine(s);
}
}

You would be able to find IO related classed under
System.IO, System.IO.File specifically provide file
manipultion functions.

Thanks,

Muhammad Arif
System Analyst, UHC
>-----Original Message-----
>I want to do something like
>
>where:
>m_Device(_T(\\\\.\\PHYSICALDRIVE1) to read drive 1
>
>I then want to read the physical device till the end and
save it in a disk
>file. Does anyone have an example of doing this in c#.
Below are the
>pertinate lines from c++. The framework does not appear
to support physical
>access.
>
>DeviceHandle = CreateFile(m_Device,
GENERIC_READ,FILE_SHARE_READ, NULL,
>OPEN_EXISTING, FILE_FLAG_NO_BUFFERING, NULL);
>
>then in a loop
>
>rc = ReadFile(DeviceHandle, buffer, sizeof(buffer),
&BytesRead, NULL);
>
>
>
>__
>
>
>
>
>
> Jim
>
>
>.
>

Re: I need to do physocal disk reads by Willy

Willy
Sat Dec 20 17:45:10 CST 2003

No physical device access from the IO classes, you need to call the API
using Pinvoke.

Willy.

"Jim" <IDONTWANTSPAM@NOTHERE.com> wrote in message
news:eym9%23xMxDHA.1736@TK2MSFTNGP09.phx.gbl...
> I want to do something like
>
> where:
> m_Device(_T(\\\\.\\PHYSICALDRIVE1) to read drive 1
>
> I then want to read the physical device till the end and save it in a disk
> file. Does anyone have an example of doing this in c#. Below are the
> pertinate lines from c++. The framework does not appear to support
physical
> access.
>
> DeviceHandle = CreateFile(m_Device, GENERIC_READ,FILE_SHARE_READ, NULL,
> OPEN_EXISTING, FILE_FLAG_NO_BUFFERING, NULL);
>
> then in a loop
>
> rc = ReadFile(DeviceHandle, buffer, sizeof(buffer), &BytesRead, NULL);
>
>
>
> __
>
>
>
>
>
> Jim
>
>