Forum Discussion

mspatel's avatar
mspatel
Contributor
10 years ago
Solved

FileExists aand FindFiles failed when No file in Folder TestComplete

aqFileSystem.FindFiles("C:\Temp\" , "*.zip" ) .count failed when there is no file or Folder in the Target Folder. 



It complains about "Object Doesnt Exist " or something...Shouldnt it Return NULL Object if nothing Exist 



Not only aqFileSystem.FindFiles("C:\Temp\" , "*.zip" ) .count  but If you just do following 



Set countFiles = aqFileSystem.FindFiles("C:\Temp\" , "*.zip" )  it will fail when There is no contents in Folder.





I am Using this to Poll folder for perticular file...



I cant use aqFileSystem.Exists(zipFilePath) because file that gets dropped to that location has dynamic names ....and Exist() methos wont accept wildcard usage like 



aqFileSystem.Exists(zipOutPutFolder&"\*.zip") --- > this will always return false ....even though file is There...







Whats the best way to Poll a directory in this situation ???

 



  • Hi.



    Here is working piece of code.






    Sub testFiles


    Dim countFiles


    Set countFiles = aqFileSystem.FindFiles("C:\Temp\" , "*.zip" )


    If countFiles Is Nothing Then


      Log.Message ( "No files found" )


    Else


      For I = 0 To countFiles.Count - 1


        Log.Message( countFiles.Item( I ).Name )


      Next   


    End If  


    End Sub  



1 Reply

  • Hi.



    Here is working piece of code.






    Sub testFiles


    Dim countFiles


    Set countFiles = aqFileSystem.FindFiles("C:\Temp\" , "*.zip" )


    If countFiles Is Nothing Then


      Log.Message ( "No files found" )


    Else


      For I = 0 To countFiles.Count - 1


        Log.Message( countFiles.Item( I ).Name )


      Next   


    End If  


    End Sub