C# PPC 獲取存儲卡的名稱

首先遍歷系統目錄,然後查看其屬性,當此目錄的屬性爲臨時時即爲存儲卡。少廢話看代碼

 

        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;
        }

發佈了40 篇原創文章 · 獲贊 4 · 訪問量 5萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章