Time:09-27
instance. TXT this file in D: \ \ test 2 folder, so his full path should be "D: \ \ test \ 2 instances. TXT"
CodePudding user response:
Dim colFiles As Collection Dim As Long I The Set colFiles=SearchFiles (" D: \ ", "instances. TXT") For I=1 To colFiles. Count The Debug. Print colFiles (I) Next
App. The Path + "" + FileName
Public Declare Function GetFileAttributesW Lib "KERNEL32. DLL" (ByVal lpFileName As Long) As Long Public Const INVALID_HANDLE_VALUE=https://bbs.csdn.net/topics/-1& Public Enum enumFileNameParts EfpFileName=2 ^ 0 EfpFileExt=2 ^ 1 EfpFilePath=2 ^ 2 EfpFileNameAndExt=efpFileName + efpFileExt EfpFileNameAndPath=efpFilePath + efpFileName End Enum The Public Function DoesFileExist (FileName As String) As Boolean 'the test to see if a file exists DoesFileExist=Not (GetFileAttributesW (StrPtr (FileName))=INVALID_HANDLE_VALUE) End the Function '=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-='the GetFileName 'This function is 2 parse keys peices of info from a 'filename that is passed into it. The Public Function GetFileName (ByVal sFile As String, ByVal ePortions As enumFileNameParts) As String Dim lFirstPeriod As Long Dim lFirstBackSlash As Long Dim sRet As String Dim sPath As String Dim sName As String Dim sExt As String LFirstPeriod=InStrRev (sFile, ". ") LFirstBackSlash=InStrRev (sFile, "") If lFirstBackSlash & gt; 0 Then SPath=VBA. Left $(sFile lFirstBackSlash) End the If If lFirstPeriod & gt; 0 And lFirstPeriod & gt; LFirstBackSlash Then SExt=Mid (sFile, lFirstPeriod + 1) SName=Mid (sFile lFirstBackSlash + 1, lFirstPeriod lFirstBackSlash - 1) The Else SName=Mid (sFile, lFirstBackSlash + 1) End the If If ePortions And efpFilePath Then SRet=sRet & amp; SPath End the If If ePortions And efpFileName Then SRet=sRet & amp; SName End the If If ePortions And efpFileExt Then If sRet & lt;> "" Then SRet=sRet & amp; ". "& amp; SExt The Else SRet=sRet & amp; SExt End the If End the If GetFileName=sRet End the Function
Page link:https//www.codepudding.com/Softwareengineering/37401.html