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

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

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

本文實(shí)例講述了C#使用shell32獲取文件屬性的方法。分享給大家供大家參考。具體實(shí)現(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('//'))); 
   //獲取文件對應(yīng)的FolderItem對象 
   FolderItem item = folder.ParseName(filePath.Substring(filePath.LastIndexOf('//')+1)); 
   //字典存放屬性名和屬性值的鍵值關(guān)系對 
   Dictionary<string, string> Properties = new Dictionary<string, string>(); 
   int i =0; 
   while (true) 
   { 
    //獲取屬性名稱 
    string key = folder.GetDetailsOf(null, i); 
    if (string.IsNullOrEmpty(key)) 
    { 
     //當(dāng)無屬性可取時(shí),推出循環(huán) 
     break; 
    } 
    //獲取屬性值 
    string value = folder.GetDetailsOf(item, i); 
    //保存屬性 
    Properties.Add(key, value); 
    i++; 
   } 
  } 
 } 
}

希望本文所述對大家的C#程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評論

台南县| 休宁县| 沂水县| 沁源县| 大丰市| 昆山市| 兴隆县| 舟山市| 加查县| 观塘区| 元谋县| 平果县| 阿巴嘎旗| 民乐县| 太仓市| 辰溪县| 鸡东县| 仁怀市| 肥城市| 敖汉旗| 黎川县| 乌鲁木齐市| 大悟县| 武隆县| 巴彦淖尔市| 衡东县| 巫溪县| 鹤庆县| 汕头市| 信阳市| 丽江市| 军事| 句容市| 东平县| 邳州市| 常山县| 赤峰市| 河曲县| 米泉市| 临潭县| 奎屯市|