Forum

> > CS2D > Scripts > os.remove
Forums overviewCS2D overview Scripts overviewLog in to reply

English os.remove

7 replies
To the start Previous 1 Next To the start

old os.remove

pbeloto
User Off Offline

Quote
help-me command os.remove.

it works only of time in when .

can anyone help me??

1
2
3
4
5
6
if cmd== "@remove_admin" then
	if usgn > 0 then
		os.remove("sys/lua/user/"..usgn..".txt")
	end
return 1
end

old Re: os.remove

MikuAuahDark
User Off Offline

Quote
Try assertion

1
assert(os.remove("sys/lua/user/"..usgn..".txt"))

And make sure that usgn variable is exist

old Re: os.remove

pbeloto
User Off Offline

Quote
user MikuAuahDark has written
Try assertion

1
assert(os.remove("sys/lua/user/"..usgn..".txt"))

And make sure that usgn variable is exist



Error

1
LUA ERROR: sys/lua/TCM/script.lua:560: sys/lua/TCM/Users/Admin/3323.txt: Permission denied

old Re: os.remove

MikuAuahDark
User Off Offline

Quote
something wrong with the file. Because it shows "Permission Denied". Make sure that the file is closed before deleting

old Re: os.remove

DannyDeth
User Off Offline

Quote
If CS2D is running from 'Program Files' in Windows, this can happen because CS2D does not have permission to modify things.

old Re: os.remove

pbeloto
User Off Offline

Quote
user MikuAuahDark has written
something wrong with the file. Because it shows "Permission Denied". Make sure that the file is closed before deleting



you have skype for help-me?

old Re: os.remove

MikuAuahDark
User Off Offline

Quote
Sorry, i don't have Skype. Well about your problem, try to inversigate all function that uses io.open function and check if it's really closed.

You may also try to collectgarbage first then removing it if you cannot find which function is causing the problem.

Add this code above os.remove
1
collectgarbage("collect")

So, the re-builded code is should like this
1
2
3
4
5
6
7
if cmd== "@remove_admin" then
	if usgn > 0 then
		collectgarbage("collect")
		assert(os.remove("sys/lua/user/"..usgn..".txt"))
	end
	return 1
end

If you still getting "Permission Denied!" then CS2D doesn't have rights to delete that file, file permissions doesn't set correctly, or both.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview