C# (asp.net) 获取文件详细备注信息
2011-11-10 16:57
579 查看
C#获取文件详细备注信息
项目中引用 Shell32.dll;(文件可以从C:\windows\system32\ 目录下拷贝,引用后自动识别成 Interop.Shell32)
using System.IO;
using Shell32;
ShellClass sh = new ShellClass();
Folder dir = sh.NameSpace(Path.GetDirectoryName(strPath));
FolderItem item = dir.ParseName(Path.GetFileName(strPath));
StringBuilder sb = new StringBuilder();
for (int i = -1; i < 50; i++)
{
// 0 Retrieves the name of the item.
// 1 Retrieves the size of the item.
// 2 Retrieves the type of the item.
// 3 Retrieves the date and time that the item was last modified.
// 4 Retrieves the attributes of the item.
// -1 Retrieves the info tip information for the item.
sb.Append(i.ToString());
sb.Append(":");
sb.Append(dir.GetDetailsOf(item, i));
sb.Append("/r/n");
}
string c = sb.ToString();
进行消化后可以整理这么个通用方法:
好了,万事无忧,放到自己的文件操作类公用库里面去,以后啥时都可以用了
项目中引用 Shell32.dll;(文件可以从C:\windows\system32\ 目录下拷贝,引用后自动识别成 Interop.Shell32)
using System.IO;
using Shell32;
ShellClass sh = new ShellClass();
Folder dir = sh.NameSpace(Path.GetDirectoryName(strPath));
FolderItem item = dir.ParseName(Path.GetFileName(strPath));
StringBuilder sb = new StringBuilder();
for (int i = -1; i < 50; i++)
{
// 0 Retrieves the name of the item.
// 1 Retrieves the size of the item.
// 2 Retrieves the type of the item.
// 3 Retrieves the date and time that the item was last modified.
// 4 Retrieves the attributes of the item.
// -1 Retrieves the info tip information for the item.
sb.Append(i.ToString());
sb.Append(":");
sb.Append(dir.GetDetailsOf(item, i));
sb.Append("/r/n");
}
string c = sb.ToString();
进行消化后可以整理这么个通用方法:
/// <summary> /// 获取媒体文件属性信息 /// </summary> /// <param name="path">媒体文件具体路径</param> /// <param name="icolumn">具体属性的顺序值(-1简介信息 1文件大小 21时长 22比特率)</param> /// <returns></returns> public static string GetMediaDetailInfo(string path,int icolumn) { try { ShellClass sh = new ShellClass(); Shell32.Folder folder = sh.NameSpace(path.Substring(0, path.LastIndexOf("\\"))); Shell32.FolderItem folderItem = folder.ParseName(path.Substring(path.LastIndexOf("\\") + 1)); return folder.GetDetailsOf(folderItem, icolumn); } catch (Exception ex) { ex.Message.ToString(); return null; } }
好了,万事无忧,放到自己的文件操作类公用库里面去,以后啥时都可以用了
相关文章推荐
- C#获取文件详细备注信息
- C#获取文件详细备注信息
- asp.net C#获取程序文件相关信息
- C#获取文件详细备注信息
- C#通过shell32获取文件详细备注信息
- asp.net C#获取程序文件相关信息
- C#获取文件详细备注信息
- C#获取文件详细备注信息,MP3的Tag等等
- C#获取FTP文件详细备注信息
- asp.net实现获取客户端详细信息
- 【Asp.Net从零开始】:创建主表格以及单击获取详细信息的数据显示图
- c#(asp.NET)获取文件路径
- ASP.NET(C#)中获取IP,名称,操作系统,浏览器等信息代码大全
- ASP.NET C# 获取客户端及浏览器信息
- ASP.NET、WinForm、C# - 配置文件信息读取 [ Web.config || Appconfig ]
- 获取文件属性中详细信息里的各项目(vb 学习备注)
- ASP.NET-C#获取当前文件的路径
- asp.net实现获取客户端详细信息
- ASP.NET C# 的Web.config文件详细介绍
- asp.net WebForm 前台获取后台c#代码信息