使用函数:

  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. OOP设计模式[JAVA]——02观察者模式

    观察者模式 观察者模式的设计原则 为交互对象之间的松耦合设计而努力,使对象之间的相互依赖降到最低. 观察者模式也是对象行为型模式,其意图为:定义对象间的一种一对多的依赖关系,当一个对象的状态发生改变时 ...

  2. IOS开发UI篇之──自定义UIActionSheet

    转载自:http://www.cnblogs.com/pengyingh/articles/2343200.html UIActionSheet类系IOS开发中实现警告框的重要的类,而在好多应用中,都 ...

  3. MFC框架中消失的WinMain()

    学过一段时间的MFC之后,很多人大概都有一个疑问:在MFC中,WinMain()哪去了?因为任何一个使用过Win32 SDK编程的人都知道,WinMain()函数是Win32程序开始的入口点,可是在M ...

  4. sqrt 源代码

    stap -v -e 'probe process("/usr/local/mysql56/bin/mysqld").function("*@/usr/src/mysql ...

  5. CSharp Algorithm - How to traverse binary tree by breadth (Part II)

    /* Author: Jiangong SUN */ Here I will introduce the breadth first traversal of binary tree. The pri ...

  6. Ubuntu下配置tftp服务

    Ubuntu下配置tftp服务 1.安装TFTP软件 sudo apt-get install tftp-hpa tftpd-hpa tftp-hpa是客户端,tftpd-hpa是服务器端 2.建立t ...

  7. 聊聊Android5.0中的水波纹效果

    水波纹效果已经不是什么稀罕的东西了,用过5.0新控件的小伙伴都知道这个效果,可是如果使用一个TextView或者Button或者其它普通控件的话,你是否知道如何给它设置水波纹效果呢?OK,我们今天就来 ...

  8. 通过配置tomcat虚拟路径配置站点的静态资源

    我们常常站点中会提供给用户上传文件.图片.视频或者诸如为了提高性能生成的静态文件等存储在站点应用中.但如果静态资源文件和项目文件在同一个目录下,当我们重新部署文件时,war重新解压会导致静态资源文件的 ...

  9. G方法的华丽升级

    ThinkPHP长期以来需要通过debug_start.debug_end方法甚至Debug类才能完成的功能,3.1版本中被一个简单的G方法取代了,不可不谓是一次华丽升级.G方法的作用包括标记位置和区 ...

  10. css怎么写链接到图片和地址