找回密码
 加入
搜索
查看: 2699|回复: 7

[AU3基础] 请教如何确定一个目录下是否只有指定的两个目录名,然后弹出提示

  [复制链接]
发表于 2011-2-11 11:44:52 | 显示全部楼层 |阅读模式
我想找一下 C:\TEST目录下

是否只有A-1和B-1两个子目录,

如果只有这个目录MSGBOX(0,0,"确定只有这两个")
ELSE
MSGBOX(0,0,"还有其他的")

查找过程不会,请教!
发表于 2011-2-11 11:50:57 | 显示全部楼层
#Include <File.au3>
_FileListToArray
 楼主| 发表于 2011-2-11 12:09:57 | 显示全部楼层
回复 2# netegg

你好,能否详细点,新手上路请多关照,看了帮助不会!
发表于 2011-2-11 12:32:47 | 显示全部楼层
本帖最后由 天煞孤心 于 2011-2-11 12:34 编辑

楼主去看看UDF函数就知道了。
发表于 2011-2-11 13:07:26 | 显示全部楼层
本帖最后由 haodd 于 2011-2-11 13:08 编辑

希望这个对你有用
#NoTrayIcon
#Region ;**** 参数创建于 ACNWrapper_GUI ****
;~ # http://www.autoitx.com  haodd  
;~ #AutoIt3Wrapper_outfile=dir list.exe
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****

Dim $i = 0
DirCreate ( "D:\test" )
While $i < 10
        DirCreate ( "D:\test" & $i)
        $i += 1
WEnd
$file = FileOpen("D:\test\set.ini", 2)

; 检查打开的文件可写
If $file = -1 Then
    MsgBox(0, "错误", "不能打开文件.")
    Exit
EndIf

FileWriteLine($file, "[路径]")
FileWriteLine($file, "路径 = D:\test")
FileWriteLine($file, "[忽略目录]")
FileWriteLine($file, ";格式 :")
FileWriteLine($file, ";目录名 = 1")
FileWriteLine($file, "0=1")
FileWriteLine($file, "2=1")
FileWriteLine($file, "4=1")
FileWriteLine($file, "6=1")
FileWriteLine($file, "8=1")

FileClose($file)

#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Include <File.au3>
Dim $Dir = IniRead("D:\test\set.ini","路径","路径","")
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Dir list", 139, 317, 763, 399)
$List1 = GUICtrlCreateList("", 8, 8, 123, 300)
 _unList()
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                
        EndSwitch
WEnd

Func _unList()
        $FileList=_FileListToArray($Dir,"*", 2)
        For $i =1  To $FileList[0]
                $unlist = IniRead("set.ini","忽略目录",$FileList[$i],"")
                If $unlist Then ContinueLoop
                GUICtrlSetData($List1, $FileList[$i])
        Next
EndFunc
发表于 2011-2-11 13:24:52 | 显示全部楼层
本帖最后由 netegg 于 2011-2-11 13:47 编辑

#Include <File.au3>
#Include <array.au3>
$aArray = _FileListToArray($path, '*', 2) ;获取目录列表
if $aArray[0] <> 2 then
msgbox(0,0, '多了或少了')
else
  $string = _arraytostring($aArray)
  if not (stringinstr($string, $dir1) and stringinstr(stirng, $dir2)) then
    msgbox(0,0,'两个目录至少有一个不对')
  endif
endif
发表于 2011-2-11 14:31:03 | 显示全部楼层
回复 6# netegg


    谢谢你朋友,搞定,你的代码里错别字有几个
发表于 2011-2-11 14:44:51 | 显示全部楼层
回复 7# zz999

不好意思拼音没学好
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-9-21 12:30 , Processed in 0.088303 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表