Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


How to delete a file with unicode name?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
OGxsdUhnXMc
How do I cheat?
Reputation: 0

Joined: 27 May 2025
Posts: 1

PostPosted: Tue May 27, 2025 3:46 am    Post subject: How to delete a file with unicode name? Reply with quote

I Was Make My Own Script For Delete A Fle With Unicode Name But It Doesn't Work, Here Is It Script:

local form = getMainForm()
local path = form.SaveDialog1.Filename
local pathutf8 = utf8ToAnsi(path)
os.remove(pathutf8)
Back to top
View user's profile Send private message  
AylinCE
Grandmaster Cheater Supreme
Reputation: 35

Joined: 16 Feb 2017
Posts: 1486

PostPosted: Tue May 27, 2025 3:16 pm    Post subject: Reply with quote

Try this 3-angle code to have the code recognize and read the current state of the file:

Code:
local form = getMainForm()
path = createOpenDialog(form)
  if path.Execute() then
     local pathutf28 = utf8ToAnsi(path.Filename)
     local pathutf38 = utf8ToAnsi(ansiToUtf8(path.Filename))
     local pathutf48 = ansiToUtf8(path.Filename)

     sleep(200)
     if pathutf28 then
        print(28, pathutf28)
        print(28, io.popen([[powershell -Command "Get-Item ']] .. pathutf28 .. [['"]]):read("*a"))
        local file = io.open(pathutf28, "r")
        if file then
           print(28,"File exists, closing it...")
           file:close()
        else
           print(28,"File not found! The path may be incorrect.")
        end
     end
     print("------------------------------>>>")
     print("------------------------------>>>")
     if pathutf38 then
        print(38, pathutf38)
        print(38, io.popen([[powershell -Command "Get-Item ']] .. pathutf38 .. [['"]]):read("*a"))
        local file = io.open(pathutf38, "r")
        if file then
           print(38, "File exists, closing it...")
           file:close()
        else
           print(38, "File not found! The path may be incorrect.")
        end
     end
     print("------------------------------>>>")
     print("------------------------------>>>")
     if pathutf48 then
        print(48, pathutf48)
        print(48, io.popen([[powershell -Command "Get-Item ']] .. pathutf48 .. [['"]]):read("*a"))
        local file = io.open(pathutf48, "r")
        if file then
           print(48, "File exists, closing it...")
           file:close()
        else
           print(48, "File not found! The path may be incorrect.")
        end
     end
  end

  path.Destroy()


Assuming "28" gives the correct result, the file deletion method could be:

Code:
local form = getMainForm()
path = createOpenDialog(form)
  if path.Execute() then
     local path_correct = utf8ToAnsi(path.Filename)
     os.remove(path_correct)
  end
path.Destroy()

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger 
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites