使用函数:

  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. 关于css中z-index 的应用

    我想很多人在应用中的会碰到这个问题,设置 z-index无效:无论设置为多高的数字都没有效果: 原因是在设置z-index之前必须满足一下两个条件: 1,给设置z-index的元素设置相应的定位值,p ...

  2. 为Windows 7的winsxs目录瘦身,谨慎。

    刚使用Win7 系统不久,前段时间在清理系统垃圾时发现,win7系统的windows文件夹下的winsxs 文件夹占用空间很大,想清理之,却提示无权限无法清理.随即在网上查了个到底,原来winsxs是 ...

  3. vmtouch - the Virtual Memory Toucher

    https://hoytech.com/vmtouch/ [root@localhost ~]# git clone git://github.com/hoytech/vmtouch.git 正克隆到 ...

  4. android开发之wheel控件使用详解

    出门在外生不起病呀,随便两盒药60多块钱.好吧,不废话了,今天我们来看看wheel控件的使用,这是GitHub上的一个开源控件,用起来十分方便,我们可以用它做许多事情,比如做一个自定义的datepic ...

  5. Java基础知识强化之集合框架笔记72:集合特点和数据结构总结

    1. 集合 (1)Collection(单列集合) List(有序,可重复):                         ArrayList:底层数据结构是数组,查询块,增删慢.线程不安全,效率 ...

  6. iOS之XIB拖拽scrollView

    在使用storyboard和xib时,我们经常要用到ScrollView,还有自动布局AutoLayout,但是ScrollView和AutoLayout 结合使用,相对来说有点复杂.根据实践,我说一 ...

  7. JVM笔记4:Java内存分配策略

    简单来说,对象内存分配主要是在堆中分配.但是分配的规则并不是固定的,取决于使用的收集器组合以及JVM内存相关参数的设定 以下介绍几条基本规则(使用的ParNew+Serial Old收集器组合): 一 ...

  8. SQLSERVER一些公用DLL的作用解释

    如果你的SQLSERVER安装在C盘的话,下面的路径就是相应SQLSERVER版本的公用DLL的存放路径 SQL2005 C:\Program Files\Microsoft SQL Server\9 ...

  9. ACM——2的n次方

    2的N次方 时间限制(普通/Java):1000MS/3000MS          运行内存限制:65536KByte 总提交:1715            测试通过:838 描述 编程精确计算2 ...

  10. 第四篇:Eclipse Android app 工程迁移到 Android Studio

    前言:这种问题当然在所难免,所幸android studio的project 工程目录远比 Eclipse 要了然. 目录对比 我们在Eclipse中创建一个EclipseDemo的Android项目 ...