Deleting folder

I am attempting to create a button to delete a folder found in a specific path.

“rd /s /Q C:\Users\%Username%\AppData\Local\My Folder\Test” --> This is the command i would use if i were to use it on a batch script

i know i can use shell but for some reason it does not work for me

Would i need to find folder item than delete?

Thanks in advance

Yes, you need to do it iterative.

there is a complete example in the language reference, at the folderitem.delete entry.

[code]
Function DeleteEntireFolder(theFolder As FolderItem, continueIfErrors As Boolean = False) As Integer
// Returns an error code if it fails, or zero if the folder was deleted successfully

Dim returnCode, lastErr, itemCount As Integer
Dim files(), dirs() As FolderItem

If theFolder = Nil Or Not theFolder.Exists() Then
Return 0
End If

// Collect the folder‘s contents first.
// This is faster than collecting them in reverse order and deleting them right away!
itemCount = theFolder.Count
For i As Integer = 1 To itemCount
Dim f As FolderItem
f = theFolder.TrueItem(i)
If f <> Nil Then
If f.Directory Then
dirs.Append(f)
Else
files.Append(f)
End If
End If
Next

// Now delete the files
For Each f As FolderItem In files
f.Delete
lastErr = f.LastErrorCode // Check if an error occurred
If lastErr <> 0 Then
If continueIfErrors Then
If returnCode = 0 Then returnCode = lastErr
Else
// Return the error code if any. This will cancel the deletion.
Return lastErr
End If
End If
Next

Redim files(-1) // free the memory used by the files array before we enter recursion

// Now delete the directories
For Each f As FolderItem In dirs
lastErr = DeleteEntireFolder(f, continueIfErrors)
If lastErr <> 0 Then
If continueIfErrors Then
If returnCode = 0 Then returnCode = lastErr
Else
// Return the error code if any. This will cancel the deletion.
Return lastErr
End If
End If
Next

If returnCode = 0 Then
// We‘re done without error, so the folder should be empty and we can delete it.
theFolder.Delete
returnCode = theFolder.LastErrorCode
End If

Return returnCode
End Function[/code]

I am still new with working with Xojo, looking at the example in the LR where do you add the path where the folder is located?

There are a bunch of FolderItems. Be more precise, please.

If you mean inside:

Function DeleteEntireFolder(theFolder As FolderItem, continueIfErrors As Boolean = False) As Integer

theFolder is a Function parameter.
You call the Function as:

Done = DeleteEntireFolder(f, True)

f is the reference of the folder you want to delete its contents. You select it using SelectFolder (for example).