The main content of this source code is to scan and delete the txt document file in the hard disk. The following are all the codes:
Subprogram Traversal Directory, , , Output all files in the specified directory,Including subdirectories .parameter Reference directory, Text type, , No last one“\” .Local variables file name, Text type .Local variables Directory array, Text type, , "0" .Local variables i, Integer type .Local variables File Type, Integer type .If true (Information box (“It will be traversed with the specified directory and delete allTXTdocument!Whether to continue?”, 1, ) ≠ 0) return () .If true结束 File Type = bit or (#Archive files, #Read-only files, #System files, #Hidden files, #Subdirectory)file name = 寻找document (choose (Take the text to the right (Reference directory, 1) ≠ “\”, Reference directory + “\”, Reference directory) + “*.*”, File Type) .If true (file name = “”) return () ' Set termination conditions .If true结束 .Cycle judgment first () .if (bit and (取document属性 (Reference directory + “\” + file name), #Subdirectory) ≠ 0) ' Note that you cannot traverse directly here, you must first save the array. ' otherwise就是开启了一个新的寻找document的过程, ' 导致无法列正确的document Join a member (Directory array, file name) ' Save the directory into the array first .otherwise .If true (to lowercase (Take the text to the right (file name, 4)) = “.txt”) 删除document (Reference directory + “\” + file name) .If true结束 ' Output debug text (Reference directory + “\” + file name) ' The file name is output .If ended ' Looking for the next one file name = 寻找document (, File Type) .Cycle judgment tail (file name ≠ “”) .Cycle first (Take the number of array members (Directory array), i) .If true (Directory array [i] ≠ “.” and Directory array [i] ≠ “..”) ' Scan not only if the current directory and parent directory are scanned Traversal Directory (Reference directory + “\” + Directory array [i]) ' 递归调用Subprogram本身 .If true结束 .Calculate the cycle ()
Thank you for your support, you can test the code content.