jscpu 发表于 2011-2-11 11:44:52

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

我想找一下 C:\TEST目录下

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

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

查找过程不会,请教!

netegg 发表于 2011-2-11 11:50:57

#Include <File.au3>
_FileListToArray

jscpu 发表于 2011-2-11 12:09:57

回复 2# netegg

你好,能否详细点,新手上路请多关照,看了帮助不会!

天煞孤心 发表于 2011-2-11 12:32:47

本帖最后由 天煞孤心 于 2011-2-11 12:34 编辑

楼主去看看UDF函数就知道了。

haodd 发表于 2011-2-11 13:07:26

本帖最后由 haodd 于 2011-2-11 13:08 编辑

希望这个对你有用#NoTrayIcon
#Region ;**** 参数创建于 ACNWrapper_GUI ****
;~ # http://www.autoitx.comhaodd
;~ #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 =1To $FileList
                $unlist = IniRead("set.ini","忽略目录",$FileList[$i],"")
                If $unlist Then ContinueLoop
                GUICtrlSetData($List1, $FileList[$i])
        Next
EndFunc

netegg 发表于 2011-2-11 13:24:52

本帖最后由 netegg 于 2011-2-11 13:47 编辑

#Include <File.au3>
#Include <array.au3>
$aArray = _FileListToArray($path, '*', 2) ;获取目录列表
if $aArray <> 2 then
msgbox(0,0, '多了或少了')
else
$string = _arraytostring($aArray)
if not (stringinstr($string, $dir1) and stringinstr(stirng, $dir2)) then
    msgbox(0,0,'两个目录至少有一个不对')
endif
endif

zz999 发表于 2011-2-11 14:31:03

回复 6# netegg


    谢谢你朋友,搞定,你的代码里错别字有几个

netegg 发表于 2011-2-11 14:44:51

回复 7# zz999

不好意思拼音没学好
页: [1]
查看完整版本: 请教如何确定一个目录下是否只有指定的两个目录名,然后弹出提示