判断方法: DirectoryInfo di = new DirectoryInfo(path); if ((di.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden) //为隐藏的 同理可以判断目录是否为只读(ReadOnly)或者系统(System)等其他属性.
FUNCTION WritableDir(CONST Dir : STRING) : BOOLEAN; VAR FIL : FILE; N : STRING; I : Cardinal; BEGIN REPEAT N:=IncludeTrailingPathDelimiter(Dir); FOR I:= TO -LENGTH(N) DO N:=N+CHAR(RANDOM()+) UNTIL NOT FileExists(N); Result:=TRUE; TRY AssignFile(FIL,N
通常作为一个应用程序的部署脚本,开始的第一项工作是为当前应用创建一个专用(dedicated)的用户和用户组.这个脚本很简单,这里贴一个参考样本: #!/bin/sh user=test_user group=test_group #create group if not exists egrep "^$group" /etc/group >& /dev/null if [ $? -ne 0 ] then groupadd $group fi #create user