国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > C# > 正文

C#使用shell32獲取文件屬性的方法

2020-01-24 01:55:54
字體:
來源:轉載
供稿:網友

本文實例講述了C#使用shell32獲取文件屬性的方法。分享給大家供大家參考。具體實現方法如下:

using System; using System.Collections.Generic; using System.Linq; using System.Text; using Shell32; namespace GetFileCreator {  class Program  {   static void Main(string[] args)   {    //要獲取屬性的文件路徑    string filePath = @"e:/f/aa.txt";    //初始化Shell接口    Shell32.Shell shell = new Shell32.ShellClass();    //獲取文件所在父目錄對象    Folder folder = shell.NameSpace(filePath.Substring(0, filePath.LastIndexOf('//')));    //獲取文件對應的FolderItem對象    FolderItem item = folder.ParseName(filePath.Substring(filePath.LastIndexOf('//')+1));    //字典存放屬性名和屬性值的鍵值關系對    Dictionary<string, string> Properties = new Dictionary<string, string>();    int i =0;    while (true)    {     //獲取屬性名稱     string key = folder.GetDetailsOf(null, i);     if (string.IsNullOrEmpty(key))     {      //當無屬性可取時,推出循環      break;     }     //獲取屬性值     string value = folder.GetDetailsOf(item, i);     //保存屬性     Properties.Add(key, value);     i++;    }   }  } }

希望本文所述對大家的C#程序設計有所幫助。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 东乡| 江西省| 巴林右旗| 台东市| 十堰市| 英吉沙县| 陇西县| 美姑县| 睢宁县| 洛扎县| 揭阳市| 山东省| 丰镇市| 鹤庆县| 新河县| 将乐县| 柳林县| 汝南县| 大厂| 密云县| 上栗县| 宁德市| 麻城市| 伊宁县| 涞水县| 三穗县| 社会| 定边县| 济南市| 额敏县| 樟树市| 永清县| 全南县| 会泽县| 稷山县| 伊春市| 门头沟区| 嵊州市| 芦山县| 永修县| 莒南县|