首先遍歷系統目錄,然後查看其屬性,當此目錄的屬性爲臨時時即爲存儲卡。少廢話看代碼
public string GetStorageCardPath()
{
string strPath = "";
System.IO.DirectoryInfo dirInfo = new System.IO.DirectoryInfo("//");
System.IO.FileSystemInfo[] fileInfos = dirInfo.GetFileSystemInfos();
int nlen = fileInfos.GetLength(0);
for (int i = 0; i < nlen; i++)
{
if (fileInfos[i].Attributes == (System.IO.FileAttributes.Directory | System.IO.FileAttributes.Temporary))
{
strPath = fileInfos[i].FullName;
strPath += "//";
break;
}
}
return strPath;
}