Hello
Can someone explain to me why it is so difficult to delete a file if you have the path?

I can't, and I don't know why.
First (see image), why does autocomplete first show the DeleteFile() function with LPCSTR.
If i chose it, i get now RawByteString oder UnicodeString?
Second. How do i delete a file, this can't be that hard.
What is wrong here?
dm_main.pas(102,39) Error: Incompatible type for arg no. 1: Got "UnicodeString", expected "PChar"
uses
Classes, SysUtils, Dialogs, Windows, LazFileUtils, LR_DBSet, LR_Class,
LR_Desgn, lr_e_pdf, uResource, uini, DB, ZConnection, ZSqlProcessor, ZDataset,
ZAbstractRODataset, DBCtrls, fileutil, LazUtf8;
//.....
procedure TdmMain.DataModuleCreate(Sender: TObject);
var
tempDirectoryPath: String;
files: TStringList;
item: String;
begin
tempDirectoryPath := ExtractFilePath(ParamStr(0))+'temp';
if not DirectoryExists(tempDirectoryPath) then
begin
CreateDir(tempDirectoryPath);
end
else
begin
try
files := TStringList.Create;
files := FindAllFiles(tempDirectoryPath,'*.*',true);
for item in files do
begin
ShowMessage(item);
DeleteFile(UTF8ToUTF16(item));
end;
finally
files.Free;
end;
end;
end;
I have created a new project and it works.

I do not understand.
uses
FileUtil, LazUtf8
//...
procedure TformMain.btnGenerateClick(Sender: TObject);
var
path: String;
files: TStringList;
item: String;
begin
path:= 'C:\Temp';
try
files := TStringList.Create;
files := FindAllFiles(path,'*.*',false);
for item in files do
begin
ShowMessage(item);
DeleteFile(UTF8ToUTF16(item));
end;
finally
files.Free;
end;
end;
Regards Int3g3r