最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

 更新時間:2015年04月24日 15:22:44   作者:令狐不聰  
這篇文章主要介紹了C#使用shell32獲取文件屬性的方法,涉及C#通過shell32獲取文件屬性的相關技巧,需要的朋友可以參考下

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

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)) 
    { 
     //當無屬性可取時,推出循環(huán) 
     break; 
    } 
    //獲取屬性值 
    string value = folder.GetDetailsOf(item, i); 
    //保存屬性 
    Properties.Add(key, value); 
    i++; 
   } 
  } 
 } 
}

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

相關文章

最新評論

昭苏县| 怀宁县| 宿松县| 桃江县| 安康市| 阜阳市| 杭州市| 利辛县| 万年县| 郯城县| 丽江市| 秀山| 怀安县| 邢台县| 南宁市| 龙山县| 建水县| 河池市| 城固县| 石城县| 塔城市| 霍山县| 互助| 县级市| 鲁山县| 隆化县| 天全县| 湖州市| 广南县| 饶河县| 武山县| 开平市| 油尖旺区| 乌海市| 铅山县| 文山县| 托克逊县| 祁阳县| 维西| 根河市| 靖江市|