SlowCoder74 Posted April 27, 2012 Posted April 27, 2012 ... but not the directory itself ... DirRemove does exactly what I need to do, except that it also deletes the parent directory, and there is no option to leave the parent. Why is this a problem? Take a directory that has specific permissions set on it. The contents need to be deleted, but if the parent directory is deleted, then recreated under my program's user context, then the original permissions are lost. What are my options? To enumerate the subs of the directory, and delete them individually?
Danyfirex Posted April 27, 2012 Posted April 27, 2012 use FileDeletefiledelete("C:UsersusuarioDesktopfolder") Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut
PhoenixXL Posted April 28, 2012 Posted April 28, 2012 May This Help U out $Folder=FileSelectFolder('Folder Whose Content To Be Deleted','') ConsoleWrite($Folder&@CRLF) $Search=FileFindFirstFile($Folder&'*.*') While True $Found=FileFindNextFile($Search) If @error Then ExitLoop If @extended Then ConsoleWrite('DirRemove:'&DirRemove($Folder&''&$Found,1)&@CRLF) ContinueLoop EndIf ConsoleWrite('FileRemove:'&FileDelete($Folder&''&$Found)&@CRLF) ConsoleWrite($Folder&''&$Found&@CRLF) WEnd Thumbs Up If Helped My code: PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners. MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.
Moderators JLogan3o13 Posted April 28, 2012 Moderators Posted April 28, 2012 (edited) Hi, SlowCoder74. This is what I use to delete all files and subfolders from a user's Temp directory. You may be able to modify it for your needs. #include <File.au3> #include <Array.au3> $_dir1 = _FileListToArray(@TempDir, "*", 2) If IsArray($_dir1) Then For $n = 1 To $_dir1[0] $sPath = @TempDir & "" & $_dir1[$n] If FileExists($sPath & "") Then DirRemove($sPath, 1) EndIf Next EndIf $_dir2 = _FileListToArray(@TempDir, "*", 1) If IsArray($_dir2) Then For $n = 1 To $_dir2[0] $sPath = "C:Temp" & $_dir2[$n] If FileExists($sPath) Then FileDelete($sPath) EndIf Next EndIf Edited April 28, 2012 by JLogan3o13 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now