Sign in to follow this  
Followers 0
CyberFunk Productions

_dirremovecontents( $spath )

2 posts in this topic

How do you use _DirRemoveContents( $sPath ), where do you put it in your code, can someone give me an example please.

Share this post

Link to post
Share on other sites

This probably should be documented better.

If you installed AutoIt with the installer, then

#include <File.au3>
; This statement usually goes at the very beginning (or very end) or your program

If you compile this script into an EXE, you do not need to distribute File.au3 with it

You can also always copy the function from "C:\Program Files\AutoIt3\Include" or where ever it is

; Code goes here
; ...
_DirRemoveContents( $someFolder )

; Function from AutoIt 3.0.100 standard library
; Author(s):        Jonathan Bennett <jon@hiddensoft com>
Func _DirRemoveContents( $sPath )
  Local $sPattern
  Local $sFile
  Local $hFile

  If StringRight( $sPath, 1 ) <> "\" Then $sPath = $sPath & "\"
  $sPattern = $sPath & "*.*"

  If Not FileExists( $sPath ) Then Return 0

  FileDelete( $sPattern )

  $hFile = FileFindFirstFile( $sPattern )
  If @error Then Return 0

  While 1
    $sFile = FileFindNextFile( $hFile )
    If @error Then ExitLoop

    If $sFile <> "." And $sFile <> ".." Then
      If StringInStr( FileGetAttrib( $sPath & $sFile ), "D" ) Then
        DirRemove( $sPath & $sFile, 1 )

  FileClose( $hFile )
  Return 1

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

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  
Followers 0