惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

美团技术团队
D
DataBreaches.Net
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
D
Docker
N
Netflix TechBlog - Medium
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
C
Check Point Blog
腾讯CDC
Stack Overflow Blog
Stack Overflow Blog
V
Visual Studio Blog
IT之家
IT之家
月光博客
月光博客
U
Unit 42
K
Kaspersky official blog
T
Threatpost
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
GbyAI
GbyAI
P
Proofpoint News Feed
Last Week in AI
Last Week in AI
云风的 BLOG
云风的 BLOG
酷 壳 – CoolShell
酷 壳 – CoolShell
I
InfoQ
Engineering at Meta
Engineering at Meta
Recorded Future
Recorded Future
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
S
Security @ Cisco Blogs
MyScale Blog
MyScale Blog
大猫的无限游戏
大猫的无限游戏
Security Archives - TechRepublic
Security Archives - TechRepublic
Webroot Blog
Webroot Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Hacker News - Newest:
Hacker News - Newest: "LLM"
S
Schneier on Security
S
Secure Thoughts
The Register - Security
The Register - Security
B
Blog RSS Feed
The Last Watchdog
The Last Watchdog
P
Palo Alto Networks Blog
爱范儿
爱范儿
B
Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
N
News and Events Feed by Topic
阮一峰的网络日志
阮一峰的网络日志
L
LINUX DO - 热门话题
C
Cisco Blogs
Spread Privacy
Spread Privacy
F
Full Disclosure
博客园 - 聂微东
T
The Blog of Author Tim Ferriss

博客园 - 北极冰点水

在.NET中使TextBox只能输入数字的方法(key 和 clipboardData) - 北极冰点水 怎样在XML中使用&和字符 ViewState深入,Textbox,Checkbox,CheckboxList,RadioButtonList 不能禁止ViewState textbox web控件 根本无视enableviewsate 是否true 或者false, 依然能够相应用户的输入 什么是One-Click技术 未将对象引用到对象的实例 asp.net执行.sql文件 和 Cmd 模式执行sql文件 - 北极冰点水 后期维护成本 用.net开发不同操作系统下应用的winform的size大小问题 怎样让用户可以跟踪查询数据库数据变化 在MembershipProvider中,现在的版本中MobileAlias 是没用的 也谈下vs2005中的gridview Vs2005 调试状态下的异常处理是比2003要好多了,布局图片也漂亮 vs2005 Gridview 得问题??? vs2005的数据库连接问题 2.0 Master Page C# 的 Delegate Type 安装SqlServer2005 Express Edit版 和 Vs 2005 CTP版 快速”格式化和常规格式化之间的区别
如何用C#代码设置文件的附加属性啊 例如author, subject 这些啊
北极冰点水 · 2008-03-05 · via 博客园 - 北极冰点水

RT
MS太麻烦了,干嘛不直接公布一个方法出来呢
我只找到了读的方法.还要用com控件, Shell32,我把那个类贴在下面,供参考

using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.IO;

namespace TestforFile
{
    using Shell32; // Use this namespace after add the reference

    /// <summary>

    /// Returns the detailed Information of a given file.

    /// </summary>

    public class CFileInfo
    {
        private string sFileName = "",
            sFullFileName = "",
            sFileExtension = "",
            sFilePath = "",
            sFileComment = "",
            sFileAuthor = "",
            sFileTitle = "",
            sFileSubject = "",
            sFileCategory = "",
            sFileType = "";

        private long lFileLength = 0,
            lFileVersion = 0;

        private DateTime dCreationDate,
            dModificationDate;

        public CFileInfo(string sFPath)
        {
            // check if the given File exists
            if (File.Exists(sFPath))
            {
                ArrayList aDetailedInfo = new ArrayList();
                FileInfo oFInfo = new FileInfo(sFPath);

                sFileName = oFInfo.Name;
                sFullFileName = oFInfo.FullName;
                sFileExtension = oFInfo.Extension;
                lFileLength = oFInfo.Length;
                sFilePath = oFInfo.Directory.ToString();
                dCreationDate = oFInfo.CreationTime;
                dModificationDate = oFInfo.LastWriteTime;

                #region "read File Details"
                aDetailedInfo = GetDetailedFileInfo(sFPath);
                foreach (DetailedFileInfo oDFI in aDetailedInfo)
                {
                    switch (oDFI.ID)
                    {
                        case 2:
                            sFileType = oDFI.Value;
                            break;

                        case 9:
                            sFileAuthor = oDFI.Value;
                            break;

                        case 10:
                            sFileTitle = oDFI.Value;
                            break;

                        case 11:
                            sFileSubject = oDFI.Value;
                            break;

                        case 12:
                            sFileCategory = oDFI.Value;
                            break;

                        case 14:
                            sFileComment = oDFI.Value;
                            break;

                        default:
                            break;
                    }
                }
                #endregion
            }
            else
            {
                throw new Exception("The given File does not exist");
            }
        }

        #region "Properties"
        public string FileName
        {
            get { return sFileName; }
            set { sFileName = value; }
        }

        public string FilePath
        {
            get { return sFilePath; }
            set { sFilePath = value; }
        }

        public string FullFileName
        {
            get { return sFullFileName; }
            set { sFullFileName = value; }
        }

        public string FileExtension
        {
            get { return sFileExtension; }
            set { sFileExtension = value; }
        }

        public long FileSize
        {
            get { return lFileLength; }
            set { lFileLength = value; }
        }

        public long FileVersion
        {
            get { return lFileVersion; }
            set { lFileVersion = value; }
        }

        public DateTime FileCreationDate
        {
            get { return dCreationDate; }
            set { dCreationDate = value; }
        }

        public DateTime FileModificationDate
        {
            get { return dModificationDate; }
            set { dModificationDate = value; }
        }

        public string FileType
        {
            get { return sFileType; }
        }

        public string FileTitle
        {
            get { return sFileTitle; }
        }

        public string FileSubject
        {
            get { return sFileSubject; }
        }

        public string FileAuthor
        {
            get { return sFileAuthor; }
        }

        public string FileCategory
        {
            get { return sFileCategory; }
        }

        public string FileComment
        {
            get { return sFileComment; }
        }
        #endregion

        #region "Methods"

        private ArrayList GetDetailedFileInfo(string sFile)
        {
            ArrayList aReturn = new ArrayList();
            if (sFile.Length > 0)
            {
                try
                {
                    // Creating a ShellClass Object from the Shell32

                    ShellClass sh = new ShellClass();
                    // Creating a Folder Object from Folder that inculdes the File
                    Folder dir = sh.NameSpace(Path.GetDirectoryName(sFile));
                    // Creating a new FolderItem from Folder that includes the File
                    FolderItem item = dir.ParseName(Path.GetFileName(sFile));
                    // loop throw the Folder Items

                    for (int i = 0; i < 30; i++)
                    {
                        // read the current detail Info from the FolderItem Object

                        //(Retrieves details about an item in a folder. For example, its size, type, or the time of its last modification.)

                        // some examples:
                        // 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.

                        string det = dir.GetDetailsOf(item, i);

                        // Create a helper Object for holding the current Information
                        // an put it into a ArrayList

                        DetailedFileInfo oFileInfo = new DetailedFileInfo(i, det);
                        aReturn.Add(oFileInfo);
                    }
                }
                catch (Exception)
                {
                }
            }
            return aReturn;
        }
        #endregion
    }

    // Helper Class from holding the detailed File Informations
    // of the System
    public class DetailedFileInfo
    {

        int iID = 0;
        string sValue = "";

        public int ID
        {
            get { return iID; }
            set
            {
                iID = value;
            }
        }

        public string Value
        {
            get { return sValue; }
            set { sValue = value; }
        }

        public DetailedFileInfo(int ID, string Value)
        {
            iID = ID;
            sValue = Value;
        }
    }
}