国产探花免费观看_亚洲丰满少妇自慰呻吟_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#程序設計有所幫助。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 永定县| 张家界市| 湾仔区| 西吉县| 南澳县| 大宁县| 马尔康县| 呼伦贝尔市| 彭阳县| 封丘县| 嘉黎县| 康保县| 莲花县| 固阳县| 建平县| 城市| 青海省| 于田县| 丰都县| 新绛县| 西贡区| 龙州县| 泰兴市| 大名县| 于都县| 榕江县| 凉城县| 思南县| 汝城县| 长顺县| 大埔县| 井冈山市| 陕西省| 万宁市| 常州市| 山丹县| 浙江省| 临沧市| 合江县| 宣汉县| 拜泉县|