views:

98

answers:

1

How do you determine if a file is on a removable drive or in the local drive in vc++?

+3  A: 

Call the GetDriveType API.

Edit:

UINT driveType = GetDriveType(lpFileName); 
if (driveType == DRIVE_FIXED) 
{ 
    /* fixed drive */ 
} 
else if (driveType == DRIVE_CDROM || driveType == DRIVE_REMOVABLE) 
{ 
    /* removable drive */ 
} 
else 
{ 
    /* other case e.g. network, RAM disk */ 
}
itowlson
can you give me an example code snippet?
blue
`UINT driveType = GetDriveType(lpFileName); if (driveType == DRIVE_FIXED) { /* fixed drive */ } else if (driveType == DRIVE_CDROM || driveType == DRIVE_REMOVABLE) { /* removable drive */ } else { /* other case e.g. network, RAM disk */ }`
itowlson