file.Delete not working on folders !

Hello all,

Again I have a problem, still on my cop folder manager. When a player disconnects it should remove his cop folder (if he has one), but it doesn’t remove the folder.

So the code just deletes all files from the folder (this part work), and after delete the folder itself (this second part of the deletion process isn’t working).

Here is my code :



function CopUpgrade:DeleteFolder(ply)
	local f = "realistic_rp/folders/" .. ply:SteamID64() .. "/"
	local files, folders = file.Find(f .. "*", "DATA")
	for k, v in pairs(files) do		
		file.Delete(f .. "/" .. v)
	end	
	file.Delete(f)	
end


[editline]13th March 2015[/editline]

Please note that the folder has no remaining files and/or folders. It’s completely empty when reaching the line file.Delete(f).

You many be using too many instances of “/”

Something like this may work:


function CopUpgrade:DeleteFolder(ply)
	local f = "realistic_rp/folders/" .. ply:SteamID64()
	local files, folders = file.Find(f .. "/*", "DATA")
	for k, v in pairs(files) do		
		file.Delete(f .. "/" .. v)
	end	
	file.Delete(f)	
end

Thanks working !