storage cards?

  • Thread starter Thread starter Katie
  • Start date Start date
K

Katie

Hi,

I use FileAttributes.Temporary with the compact framework to find storage
cards (SD & CF .) on a Pocket PC. However, using FileAttributes.Temporary
doesn't work using the regular .NET Framework on my desktop PC. Does anyone
know how I can determine if a drive on the desktop PC is a removable card?



Thanks
 
On the desktop you can use Environment.GetLogicalDrives to return an array
of all physical drives on the PC. However I'm not sure of a way to determine
whether a drive is removable or not from the desktop framework.

Peter
 
On the desktop you need to PInvoke GetDriveType()

if ( GetDriveType(@"E:\") == DriveType.DRIVE_REMOVABLE)
{
....
}
[DllImport("kernel32")]DriveType GetDriveType( string lpRootPathName );enum DriveType{ DRIVE_UNKNOWN =0, DRIVE_NO_ROOT_DIR =1, DRIVE_REMOVABLE =2, DRIVE_FIXED =3, DRIVE_REMOTE =4, DRIVE_CDROM =5, DRIVE_RAMDISK =6}
 
Thanks peter.

I found that i can use the COM FileSystemObject and Drives.DriveType to get
removable info but i would rather not use COM if i can get the same
information using the framework.

If i find the answer i will let you know

thanks
 
Back
Top