使用函数:

  System.IOUtils.TDirectory.GetAttributes//获取属性
  System.IOUtils.TDirectory.SetAttributes//设置属性

注:次例未添加异常处理。

补充一句代码:

CheckListBox1.CheckAll(vcl.StdCtrls.TCheckBoxState(0), False, False);//ListCheckBox取消所有选中

示例:

代码:

unit Unit1;

interface

uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, System.TypInfo, Vcl.StdCtrls,
Vcl.CheckLst, Vcl.FileCtrl, System.IOUtils; type
TForm1 = class(TForm)
Button_ChooseFolder: TButton;
Button_GetAttrs: TButton;
Button_SetAttrs: TButton;
CheckListBox1: TCheckListBox;
Label1: TLabel;
Edit_Path: TEdit;
procedure Button_ChooseFolderClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button_GetAttrsClick(Sender: TObject);
procedure Button_SetAttrsClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end; var
Form1: TForm1; implementation {$R *.dfm} var
sDir: string; procedure TForm1.Button_ChooseFolderClick(Sender: TObject);
begin
if not SelectDirectory('请选择一个文件夹', 'H:\', sDir) then
Exit;
Edit_Path.Text := sDir;
Button_SetAttrs.Enabled := True;
Button_GetAttrs.Enabled := True;
end; procedure TForm1.Button_GetAttrsClick(Sender: TObject);
var
FileAttrs: TFileAttributes;
FileAttr: TFileAttribute;
I: Integer;
str: string;
begin
FileAttrs := TDirectory.GetAttributes(sDir);
for FileAttr := Low(TFileAttribute) to High(TFileAttribute) do
begin
if FileAttr in FileAttrs then
str := GetEnumName
(TypeInfo(TFileAttribute), Ord(FileAttr));
for I := to CheckListBox1.Count - do
begin
if CheckListBox1.Items[I] = str then
CheckListBox1.Checked[I] := True;
end; end; end; procedure TForm1.Button_SetAttrsClick(Sender: TObject);
var
FileAttrs: TFileAttributes;
FileAttr: TFileAttribute;
I: Integer;
begin
//设置属性
FileAttrs := [];
for I := to CheckListBox1.Count - do
begin
if CheckListBox1.Checked[I] then
FileAttrs := FileAttrs + [TFileAttribute(I)];
end;
TDirectory.SetAttributes(Edit_Path.Text, FileAttrs); end; procedure TForm1.FormCreate(Sender: TObject);
begin
Button_SetAttrs.Enabled := False;
Button_GetAttrs.Enabled := False;
Edit_Path.ReadOnly := True;
end; end.

TDirectory.GetAttributes、TDirectory.SetAttributes获取和设置文件夹属性的更多相关文章

  1. TDirectory.GetCreationTime、TDirectory.SetCreationTime获取和设置文件夹创建时间

    使用函数: System.IOUtils.TDirectory.GetCreationTime//获取创建时间 System.IOUtils.TDirectory.SetCreationTime//设 ...

  2. Java根路径设置(在获取本地路径时会获取到这个文件夹,,这样就可以专门放配置文件了)

    在获取本地路径时会获取到这个文件夹,,这样就可以专门放配置文件了

  3. 获取WINDOWS特殊文件夹

    const// registry entries for special paths are kept in :  REGSTR_PATH_SPECIAL_FOLDERS   = REGSTR_PAT ...

  4. [sharepoint]rest api文档库文件上传,下载,拷贝,剪切,删除文件,创建文件夹,修改文件夹属性,删除文件夹,获取文档列表

    写在前面 最近对文档库的知识点进行了整理,也就有了这篇文章,当时查找这些接口,并用在实践中,确实废了一些功夫,也为了让更多的人走更少的弯路. 系列文章 sharepoint环境安装过程中几点需要注意的 ...

  5. java 弹出选择目录框(选择文件夹),获取选择的文件夹路径

    java 弹出选择目录框(选择文件夹),获取选择的文件夹路径 java 弹出选择目录框(选择文件夹),获取选择的文件夹路径:int result = 0;File file = null;String ...

  6. 怎样用vb设置文件夹权限?解决办法

    原文链接: http://www.reader8.cn/jiaocheng/20120201/1805958.html 怎样用vb设置文件夹权限?现在做的程序需要对win2000和win2003的文件 ...

  7. windows设置文件夹显示缩略图

      windows设置文件夹显示缩略图 CreateTime--2017年7月26日16:32:59Author:Marydon 为什么要显示缩略图? a.显示缩略图后,图片文件能够直接显示内容,不能 ...

  8. linux系统常用命令 -设置文件夹读写权限

    设置文件夹的读写权限: sudo chmod -R 777 /data 权限码描述 sudo chmod 600 ××× (只有所有者有读和写的权限)sudo chmod 644 ××× (所有者有读 ...

  9. linux 批量设置文件夹755 文件644权限

    linux 批量设置文件夹755 文件644权限 文件来源 http://www.111cn.net/sys/linux/109724.htm 本文章来为各位介绍一篇关于linux 批量设置文件夹75 ...

随机推荐

  1. window nginx 启动无提示错误,却没有listen 80port

    一直使用虚拟机来使用web+hostonly方式; 今天为了測试一个php平台的window系统兼容性, 在官方下载了window-nginx 1.9.1版本号; 解压到文件夹, 执行nginx.ex ...

  2. 【14】在资源管理类中小心copying行为

    1.为什么要使用资源管理类? 资源管理类的思路就是,栈上的对象,封装堆上分配的资源,确保一定会释放资源.auto_ptr和shared_ptr就是资源管理类,行为上像指针. 2.auto_ptr和sh ...

  3. java.lang.ClassNotFoundException: Didn't find class "*****Activity" on path: /data/app/*******.apk

    http://blog.csdn.net/lovexieyuan520/article/details/9032797/ 很多人出现了java.lang.RuntimeException: Unabl ...

  4. yum在线升级

    RPM优点 由於 RPM 是透过预先编译并打包成为 RPM 文件格式后,再加以安装的一种方式,并且还能够进行数据库的记载. 所以 RPM 有以下的优点: RPM 内含已经编译过的程序与配置档等数据,可 ...

  5. MAC地址查询 Linux/Unix操作系统mac地址怎么查

    Linux/Unix操作系统熟悉的人都通常是用console命令控制台来进行相应的操作.  Linux/Unix操作系统查看网卡mac地址的方法可以通过以下命令获得: 1.ifconfig -a 2. ...

  6. bootstrap系列整理

    去年的九月份做第一版文档站时, 就开始尝试使用bootstrap ,由于当时对node 还一知半解,大部分精力放在nodejs上,bootstrap只是拿来就用,起步文档都没看: 当别人提到 Norm ...

  7. Linux Bash终端快捷键小结

    Ctrl + A  定位至行首 Ctrl + E  定位至行尾 Ctrl + U  向前删除至行首 Ctrl + K  向后删除至行尾 Ctrl + L  清屏

  8. what is delta simulation time

    In digital logic simulation, a delta cycles are evaluation of expressions, followed by value updates ...

  9. 【腾讯Bugly干货分享】RecyclerView 必知必会

    本文来自于腾讯Bugly公众号(weixinBugly),未经作者同意,请勿转载,原文地址:http://mp.weixin.qq.com/s/CzrKotyupXbYY6EY2HP_dA 导语 Re ...

  10. 【转】【2015MIIC】迅雷CTO陈磊:互联网思维会害死很多传统企业

    MIIC2015大会的“跨界与重构”论坛上,迅雷CTO.网心科技CEO陈磊的演讲引起众多共鸣——独家揭秘“互联网大忽悠”,给这群人画了像,互联网大忽悠通常有五招: 第1招,画大饼,给你一个宏伟的目标: ...