Forum

> > CS2D > Scripts > os.remove
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch os.remove

7 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt os.remove

pbeloto
User Off Offline

Zitieren
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

alt Re: os.remove

MikuAuahDark
User Off Offline

Zitieren
Try assertion

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

And make sure that usgn variable is exist

alt Re: os.remove

pbeloto
User Off Offline

Zitieren
user MikuAuahDark hat geschrieben
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

alt Re: os.remove

MikuAuahDark
User Off Offline

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

alt Re: os.remove

DannyDeth
User Off Offline

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

alt Re: os.remove

pbeloto
User Off Offline

Zitieren
user MikuAuahDark hat geschrieben
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?

alt Re: os.remove

MikuAuahDark
User Off Offline

Zitieren
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.
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht