Jump to content
Sign in to follow this  
msb5150

Check folder is empty

Recommended Posts

msb5150

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.

Share this post


Link to post
Share on other sites
Valik

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

Share this post


Link to post
Share on other sites
msb5150

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

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.