使用函数:

  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. 电话qie听器

    业务逻辑: 当有电话打进来或电话打出去的时候,对电话进行录音. public class TelphoneyListenerService extends Service { private stat ...

  2. linux mysql 卸载后重装

    $sudo apt-get remove mysql-common清理残留数据:$sudo dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -P ...

  3. Java出现No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing--转

    原文:http://blog.csdn.net/sunny2038/article/details/6926079 最近在看Java,在编译写书上一个例子时,由于书上的代码只有一部分,于是就自己补了一 ...

  4. 常用工具之stunnel

    The stunnel program is designed to work as an SSL encryption wrapper between remote client and local ...

  5. 关于AFNetworking访问网络超时的设置

    前言:有的猿会发现在设置AFNetworking访问网络超时时,直接用self.manager.requestSerializer.timeoutInterval =10.f不起作用. 解决办法:经过 ...

  6. Android开发百度地图(一)--显示基本地图

    最近由于比赛的需要,自己学习了一下百度地图的开发.希望以下的内容能够对大家有用. 一.开发前的准备工作: 1.注册百度账号,并登录.(有百度账号的话直接登录) 2.申请Key,地址:http://de ...

  7. react环境搭建

    react-webpack文件夹是开发目录,在此目录下执行命令,假设你已经正确安装了 nodejs 一:参照教程搭建环境 https://github.com/newtriks/generator-r ...

  8. order by跟group by 跟having(2)

  9. 理解C#中的继承

    继承 1.创建子类对象的时候,在子类对象中会为子类对象的字段开辟空间,也会为父类对象的所有字段开辟空间.只不过父类私有的成员访问不到而已. 2.base关键字可以调用父类的非私有成员. 3.子类的访问 ...

  10. Canvas 笔记(持续更新中)

    1.从线条开始 HTML <canvas id="canvas"></canvas> Javascript var canvas=document.getE ...