QQ聊天

MaxScript使用.net获取全部文件的方式

Fn SetDirectoryAccessControlType inputDirectoryInfo =
(
    tempUserName = (DotNetClass "System.Environment").UserName
    fileSystemRights = (DotNetClass "System.Security.AccessControl.FileSystemRights").Modify
    accessControlType = (DotNetClass "System.Security.AccessControl.AccessControlType").Allow
    fileSystemAccessRule = DotNetObject "System.Security.AccessControl.FileSystemAccessRule" tempUserName fileSystemRights accessControlType
    directorySecurity = inputDirectoryInfo .GetAccessControl()
    directorySecurity.AddAccessRule fileSystemAccessRule
    inputDirectoryInfo .SetAccessControl directorySecurity
)

Fn GetAllFiles targetPath fileFilter  =
(
    local SearchOption,DotNetDirectoryInfo
    SearchOption = DotNetClass "System.IO.SearchOption"
    DotNetDirectoryInfo = DotNetObject "System.IO.DirectoryInfo" targetPath
    SetDirectoryAccessControlType DotNetDirectoryInfo
    result = for tfi in (DotNetDirectoryInfo.GetFiles fileFilter SearchOption.AllDirectories) collect tfi.FullName
    result
)

GetAllFiles
"E:\\" "*"

posted @ 2011-06-10 14:52  SITT  阅读(860)  评论(2编辑  收藏  举报
QQ聊天