tcbyjason 发表于 2009-7-2 17:55:03

获取文件名的问题

本帖最后由 tcbyjason 于 2009-7-3 21:30 编辑

Search("D:\", "")
Func Search($current, $ext)
      Local $search = FileFindFirstFile($current & "\*.*")
      While 1
                Dim $file = FileFindNextFile($search)
                If @error Or StringLen($file) < 1 Then ExitLoop
                If Not StringInStr(FileGetAttrib($current & "\" & $file), "D") And ($file <> "."Or $file <> "..") Then
                        If StringRight($current & "\" & $file, StringLen($ext)) = $ext Then
                              MsgBox(0,0,$current & "\" & $file)
                        EndIf
                EndIf
                If StringInStr(FileGetAttrib($current & "\" & $file), "D") And ($file <> "."Or $file <> "..") Then
                        Search($current & "\" & $file, $ext)
               
                EndIf
      WEnd
      Return
EndFunc   ;==>Search

tcbyjason 发表于 2009-7-2 17:56:16

本帖最后由 tcbyjason 于 2009-7-2 17:57 编辑

上面那代码是在论坛找到的,我想知道如果要把结果保存为文件如何搞?
例如我要把结果保存成一个文本文档,扫描出来的文件名要带有完整路径。
还有,如何修改才能让它自己扫描整个硬盘的文件?

大绯狼 发表于 2009-7-2 18:32:47

$txt = FileOpen("txt.txt", 1)
$var = DriveGetDrive("FIXED")
If Not @error Then
        For $i = 1 To $var
                Search($var[$i] & "\", "")
        Next
EndIf


Func Search($current, $ext)
        Local $search = FileFindFirstFile($current & "\*.*")
        While 1
                Dim $file = FileFindNextFile($search)
                If @error Or StringLen($file) < 1 Then ExitLoop
                If Not StringInStr(FileGetAttrib($current & "\" & $file), "D") And ($file <> "."Or $file <> "..") Then
                        If StringRight($current & "\" & $file, StringLen($ext)) = $ext Then
;~                                 MsgBox(0, 0, $current & "\" & $file)
                                FileWriteLine($txt, $current & "\" & $file)
                        EndIf
                EndIf
                If StringInStr(FileGetAttrib($current & "\" & $file), "D") And ($file <> "."Or $file <> "..") Then
                        Search($current & "\" & $file, $ext)
                EndIf
        WEnd
        Return
EndFunc   ;==>Search

tcbyjason 发表于 2009-7-2 21:35:21

本帖最后由 tcbyjason 于 2009-7-2 22:38 编辑

我想程序扫描除了C盘之外的盘应该怎么弄?(知道怎么修改代码,但是不会弄配置文件)
还有个问题就是,用文本文档保存的话,数据太多就难打开了。(希望能在配置文件指定要保存的文件类型)
最好能弄个进度条,显示扫到什么地方。

netegg 发表于 2009-7-4 13:30:58

那只是个函数而已,进度条可以自己加

muxingwan 发表于 2009-7-13 15:59:16

真是不错的东西,收了
页: [1]
查看完整版本: 获取文件名的问题