local function uninstall(directory) for i,v in ipairs(fs.list(directory)) do fs.delete(v) end end
[Help] Uninstall function
#1
Posted 25 September 2012 - 01:33 AM
#2
Posted 25 September 2012 - 03:23 AM
#3
Posted 25 September 2012 - 12:56 PM
fs.delete("[directory]")
OR to delete a directory inside a directory:fs.delete("[directory/directory]")
If there are files in lets say the root folder of the computer or disk (Not in a folder/directory) then you might be able to make a table containing the file's names and stuff. Otherwise I think you will have to add something like this:
fs.delete("[file1]")
fs.delete("[file2]")
If this doesn't work for you then sorry! But it has worked for me so I would expect it to work for you.
ALSO: If you were referring to deleting all the files inside the folder without deleting the folder, I don't know how to do that without deleting it, BUT you COULD do this:
fs.delete("[directory]")
fs.makeDir("[directory]")
Which should delete all the files inside and recreate the directory.
#4
Posted 25 September 2012 - 04:44 PM
lieudusty, on 25 September 2012 - 03:23 AM, said:
ChaddJackson12, on 25 September 2012 - 12:56 PM, said:
fs.delete("[directory]")
fs.makeDir("[directory]")
Which should delete all the files inside and recreate the directory.#5
Posted 25 September 2012 - 09:47 PM
Cranium, on 25 September 2012 - 04:44 PM, said:
lieudusty, on 25 September 2012 - 03:23 AM, said:
ChaddJackson12, on 25 September 2012 - 12:56 PM, said:
fs.delete("[directory]")
fs.makeDir("[directory]")
Which should delete all the files inside and recreate the directory.That's weird that it does not work for you, as it works for me! :/
#6
Posted 25 September 2012 - 09:53 PM
#7
Posted 25 September 2012 - 10:00 PM
fs.delete("/DirName")
#8
Posted 25 September 2012 - 10:07 PM
for i,v in ipairs(fs.list(".MCS")) do --tried ipairs
fs.delete(v)
end
for i,v in pairs(fs.list(".MCS")) do --tried pairs
fs.delete(v)
end
for i,v in pairs(fs.list(".MCS")) do
print(v) --it printed all the files listed in /.MCS
end
I tried all of those loops, but it never did delete the files, but it would print the filenames. I wonder why that is?
#9
Posted 25 September 2012 - 10:52 PM
local function uninstall(path)
for _,file in ipairs(fs.list(path)) do
fs.delete(fs.combine(path, file))
end
end
#10
Posted 25 September 2012 - 11:03 PM
local function uninstall(path)
for i,v in ipairs(fs.list(path)) do
fs.delete(fs.combine(path, v))
end
end
uninstall(".MCS")
So that would work?^
#11
Posted 25 September 2012 - 11:08 PM
#12
Posted 26 September 2012 - 02:47 AM
MysticT, on 25 September 2012 - 10:52 PM, said:
local function uninstall(path) for _,file in ipairs(fs.list(path)) do fs.delete(fs.combine(path, file)) end end
#13
Posted 26 September 2012 - 05:41 AM
For is a loop. You will find info about your question in this link
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











