Как узнать название съемного диска в WM?

В Windows Mobile, для того чтобы выяснить как называется съемный диск в системе можно воспользоваться следующим методом:

private string GetStorageCard()
{
    //initialize the path as an empty string
    string firstCard = "";

    System.IO.DirectoryInfo di = new System.IO.DirectoryInfo("\\");
    System.IO.FileSystemInfo[] fsi = di.GetFileSystemInfos();

    //iterate through them
    for (int x = 0; x < fsi.Length; x++)
    {
        //check to see if this is a temporary storage card (e.g. SD card)
        if ((fsi[x].Attributes & System.IO.FileAttributes.Temporary) == System.IO.FileAttributes.Temporary)
        {
            //if so, return the path
            firstCard = fsi[x].FullName;
        }
    }
    return firstCard;
}

P.S.
Не забываем подключать using System.IO;

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,