Jump to content

Check folder is empty


msb5150
 Share

Recommended Posts

I am writing a batch program for a video compressor, and a requirement for inputed folders (through FileSelectFolder dialoge) is that the chosen destination folder be empty, I have tried to check the size of the folder and find the first and next files however those methods have failed, or perhaps I have implemented them incorrectly. The implementation of the code, minus whatever method I need to check that the folder selected is as follows:

$ddcount = 0
    While $ddcount = 0
  $allfiles = $temp & "\*.*";an attempt to check that the folder is empty
  $rvar = FileFindFirstFile($allfiles)
  If @error = 0 Then
     $temp = FileSelectFolder($derror2, "My Computer", 1)
     If @error = 1 Then
    Exit
     EndIf
  Else
     $ddcount = 1
  EndIf
    WEnd

Any and all help is appreciated, I'm sure I'm missing something simple here but the solution has of yet alluded me.

Link to comment
Share on other sites

Why not have the user select a directory, then you create your own directory inside the one they selected? This would ensure that you have an empty directory.

By the way, using "My Computer" doesn't open FileSelectFolder to that folder, it's still opened to the "Desktop". You have to use the CLSID for "My Computer". See this thread for more details:

http://www.hiddensoft.com/forum/index.php?...ileselectfolder

Link to comment
Share on other sites

Thank you, i had noticed that but was not sure if it was some sort of aberration due to the specific folder I had chosen whilst testing the code. So the FileFindFirstFile will always return a '.' if the directory it scans is empty? That makes my life much simpler, thank you.

Edited by msb5150
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...