Sylloge
A C# helper library
Public Member Functions | Static Public Member Functions | Properties | Events
Sylloge.FileSystem.Drive Class Reference

Provides 'file-like' low level access to physical or logical drives. More...

List of all members.

Public Member Functions

delegate void DelegateError (Sylloge.FileSystem.Drive sender, string error)
 Defines a delegate function to handle the Sylloge.FileSystem.Drive.Error event.
 Drive ()
 The default constructor.
 Drive (string letterOrDeviceID)
 Creates and opens a new instance with a specified drive letter or device ID.
 Drive (string letterOrDeviceID, bool open)
 Create a new instance with a specified drive letter or device ID.
void Dispose ()
 Closes this instance and frees any attached resources.
void Close ()
 Close all handles to the device.
Sylloge.FileSystem.Drive Clone ()
 Create a deep copy of the current drive.
int DeletePartitionInformation ()
 Deletes the partition information from the drive. Once this is done, the drive is in RAW mode.
int Eject ()
 Eject the current device if it is a removable device (thumb drive, etc.)
bool Open (string driveLetterOrDeviceId)
 Open a device or logical volume.
bool Open ()
 Open the default device or logical volume.
byte[] Read (ulong sector)
 Read 'BytesPerSector' number of bytes from the disk starting at 'sector'.
byte[] Read (ulong sector, int count)
 Read 'count' number of bytes from the disk starting at 'sector'.
bool Seek (ulong sector, System.IO.SeekOrigin origin)
 Seek to a location on the device.
override string ToString ()
 Returns a string representation of the current device.
bool Write (ulong sector, byte[] data)
 Write data starting at 'sector'.

Static Public Member Functions

static Sylloge.FileSystem.Drive[] GetDrives (bool autoOpen)
 Gets the phyical drives attached to the machine.
static Sylloge.FileSystem.Drive[] GetVolumes (bool autoOpen)
 Gets the logical drives attached to the machine.

Properties

int BytesPerSector [get, set]
 Gets the bytes per sector of the device.
string Caption [get, set]
 Gets the text displayed for the device.
string DeviceID [get, set]
 Gets the physical device id (\.) or logical volume letter associated with the device.
string[] DriveLetters [get, set]
 If accessing the device as a physical device, this returns any drive letters (logical Windows partitions) associated with the device.
string Description [get, set]
 Gets the description of the devices.
ulong FreeSpace [get, set]
 Gets the free space on the device.
Microsoft.Win32.SafeHandles.SafeFileHandle Handle [get, set]
 Gets the SafeFileHandle used to access the device.
bool IsLogicalDrive [get, set]
 Gets a value indicating if the device is a logical drive (true for yes, false for physical device)
string Name [get, set]
 Gets the name of the device.
uint Partitions [get, set]
 Gets the number of partitions on the device.
uint SectorsPerTrack [get, set]
 Gets the sectors per track of the device.
ulong Size [get, set]
 Gets the total size of the device.
long TotalCylinders [get, set]
 Gets the total cylinders of the device.
ulong TotalSectors [get, set]
 Gets the total sectors on the device.
ulong TotalTracks [get, set]
 Gets the total tracks on the device.
uint TracksPerCylinder [get, set]
 Gets the tracks per cylinder of the device.
System.IO.DriveType Type [get, set]
 Gets what kind of device this is as a System.IO.DriveType enum value.
ulong UsedSpace [get, set]
 Gets the used space of the device.
bool IsReady [get]
 Gets if the current device is ready for IO.
bool IsOpen [get, set]
 Gets if the current device is open and ready for IO.
string MediaType [get]
 Gets a string representation of what type of media the device is (i.e. CD ROM, USB DEVICE, etc.)
long Position [get]
 Gets the current byte position of the stream.

Events

DelegateError Error
 Occurs when an error has happened when preforming an operation on the device.

Detailed Description

Provides 'file-like' low level access to physical or logical drives.

Definition at line 29 of file Drive.cs.


Constructor & Destructor Documentation

Sylloge.FileSystem.Drive.Drive ( )

The default constructor.

Definition at line 141 of file Drive.cs.

Sylloge.FileSystem.Drive.Drive ( string  letterOrDeviceID)

Creates and opens a new instance with a specified drive letter or device ID.

Parameters:
letterOrDeviceIDThe physical device id (\.) or logical drive letter

Definition at line 149 of file Drive.cs.

Sylloge.FileSystem.Drive.Drive ( string  letterOrDeviceID,
bool  open 
)

Create a new instance with a specified drive letter or device ID.

Parameters:
letterOrDeviceIDThe physical device id (\.) or logical drive letter
openTrue to open the device

Definition at line 160 of file Drive.cs.


Member Function Documentation

Sylloge.FileSystem.Drive Sylloge.FileSystem.Drive.Clone ( )

Create a deep copy of the current drive.

Returns:
A copy of the current instance

Definition at line 206 of file Drive.cs.

void Sylloge.FileSystem.Drive.Close ( )

Close all handles to the device.

Definition at line 186 of file Drive.cs.

delegate void Sylloge.FileSystem.Drive.DelegateError ( Sylloge.FileSystem.Drive  sender,
string  error 
)

Defines a delegate function to handle the Sylloge.FileSystem.Drive.Error event.

Parameters:
senderThe Sylloge.FileSystem.Drive object who raised the event
errorThe error string
int Sylloge.FileSystem.Drive.DeletePartitionInformation ( )

Deletes the partition information from the drive. Once this is done, the drive is in RAW mode.

Returns:
0 on success, -1 if the drive is not ready, the system error code otherwise

Definition at line 225 of file Drive.cs.

void Sylloge.FileSystem.Drive.Dispose ( )

Closes this instance and frees any attached resources.

Definition at line 177 of file Drive.cs.

int Sylloge.FileSystem.Drive.Eject ( )

Eject the current device if it is a removable device (thumb drive, etc.)

Returns:

Definition at line 240 of file Drive.cs.

static Sylloge.FileSystem.Drive [] Sylloge.FileSystem.Drive.GetDrives ( bool  autoOpen) [static]

Gets the phyical drives attached to the machine.

Parameters:
autoOpenTrue to automatically open the devices when putting them in the array
Returns:
An array containing the drives

Definition at line 630 of file Drive.cs.

static Sylloge.FileSystem.Drive [] Sylloge.FileSystem.Drive.GetVolumes ( bool  autoOpen) [static]

Gets the logical drives attached to the machine.

Parameters:
autoOpenTrue to automatically open the drives when putting them in the array
Returns:
An array containing the drives

Definition at line 645 of file Drive.cs.

bool Sylloge.FileSystem.Drive.Open ( )

Open the default device or logical volume.

Returns:

Definition at line 401 of file Drive.cs.

bool Sylloge.FileSystem.Drive.Open ( string  driveLetterOrDeviceId)

Open a device or logical volume.

Parameters:
driveLetterOrDeviceIdThe physical device id (\.) or logical drive letter
Returns:

Definition at line 389 of file Drive.cs.

byte [] Sylloge.FileSystem.Drive.Read ( ulong  sector)

Read 'BytesPerSector' number of bytes from the disk starting at 'sector'.

Parameters:
sectorThe sector to read from
Returns:

Definition at line 485 of file Drive.cs.

byte [] Sylloge.FileSystem.Drive.Read ( ulong  sector,
int  count 
)

Read 'count' number of bytes from the disk starting at 'sector'.

Parameters:
sectorThe sector to read from
countThe number of sectors to read
Returns:

Definition at line 515 of file Drive.cs.

bool Sylloge.FileSystem.Drive.Seek ( ulong  sector,
System.IO.SeekOrigin  origin 
)

Seek to a location on the device.

Parameters:
sectorThe sector to seek to
originThe origin to start the seek from
Returns:

Definition at line 545 of file Drive.cs.

override string Sylloge.FileSystem.Drive.ToString ( )

Returns a string representation of the current device.

Returns:

Definition at line 570 of file Drive.cs.

bool Sylloge.FileSystem.Drive.Write ( ulong  sector,
byte[]  data 
)

Write data starting at 'sector'.

Parameters:
sectorThe sector to start writing at
dataThe data to write to the disk. The number bytes in data must be divisiable by BytesPerSector
Returns:

Definition at line 597 of file Drive.cs.


Property Documentation

int Sylloge.FileSystem.Drive.BytesPerSector [get, set]

Gets the bytes per sector of the device.

Definition at line 60 of file Drive.cs.

string Sylloge.FileSystem.Drive.Caption [get, set]

Gets the text displayed for the device.

Definition at line 64 of file Drive.cs.

string Sylloge.FileSystem.Drive.Description [get, set]

Gets the description of the devices.

Definition at line 76 of file Drive.cs.

string Sylloge.FileSystem.Drive.DeviceID [get, set]

Gets the physical device id (\.) or logical volume letter associated with the device.

Definition at line 68 of file Drive.cs.

string [] Sylloge.FileSystem.Drive.DriveLetters [get, set]

If accessing the device as a physical device, this returns any drive letters (logical Windows partitions) associated with the device.

Definition at line 72 of file Drive.cs.

ulong Sylloge.FileSystem.Drive.FreeSpace [get, set]

Gets the free space on the device.

Definition at line 80 of file Drive.cs.

Microsoft.Win32.SafeHandles.SafeFileHandle Sylloge.FileSystem.Drive.Handle [get, set]

Gets the SafeFileHandle used to access the device.

Definition at line 84 of file Drive.cs.

bool Sylloge.FileSystem.Drive.IsLogicalDrive [get, set]

Gets a value indicating if the device is a logical drive (true for yes, false for physical device)

Definition at line 88 of file Drive.cs.

bool Sylloge.FileSystem.Drive.IsOpen [get, set]

Gets if the current device is open and ready for IO.

Definition at line 362 of file Drive.cs.

bool Sylloge.FileSystem.Drive.IsReady [get]

Gets if the current device is ready for IO.

Definition at line 346 of file Drive.cs.

string Sylloge.FileSystem.Drive.MediaType [get]

Gets a string representation of what type of media the device is (i.e. CD ROM, USB DEVICE, etc.)

Definition at line 377 of file Drive.cs.

string Sylloge.FileSystem.Drive.Name [get, set]

Gets the name of the device.

Definition at line 92 of file Drive.cs.

uint Sylloge.FileSystem.Drive.Partitions [get, set]

Gets the number of partitions on the device.

Definition at line 96 of file Drive.cs.

long Sylloge.FileSystem.Drive.Position [get]

Gets the current byte position of the stream.

Definition at line 473 of file Drive.cs.

uint Sylloge.FileSystem.Drive.SectorsPerTrack [get, set]

Gets the sectors per track of the device.

Definition at line 100 of file Drive.cs.

ulong Sylloge.FileSystem.Drive.Size [get, set]

Gets the total size of the device.

Definition at line 104 of file Drive.cs.

long Sylloge.FileSystem.Drive.TotalCylinders [get, set]

Gets the total cylinders of the device.

Definition at line 108 of file Drive.cs.

ulong Sylloge.FileSystem.Drive.TotalSectors [get, set]

Gets the total sectors on the device.

Definition at line 112 of file Drive.cs.

ulong Sylloge.FileSystem.Drive.TotalTracks [get, set]

Gets the total tracks on the device.

Definition at line 116 of file Drive.cs.

uint Sylloge.FileSystem.Drive.TracksPerCylinder [get, set]

Gets the tracks per cylinder of the device.

Definition at line 120 of file Drive.cs.

System.IO.DriveType Sylloge.FileSystem.Drive.Type [get, set]

Gets what kind of device this is as a System.IO.DriveType enum value.

Definition at line 124 of file Drive.cs.

ulong Sylloge.FileSystem.Drive.UsedSpace [get, set]

Gets the used space of the device.

Definition at line 128 of file Drive.cs.


Event Documentation

DelegateError Sylloge.FileSystem.Drive.Error

Occurs when an error has happened when preforming an operation on the device.

Definition at line 42 of file Drive.cs.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Enumerations Properties Events