HanzoDeceptor
asked on
How to get all files and directory recursively that using Unicode character in Delphi
Hi all
I want to search all files and directory recursively in a folder. example 'C:\WINDOWS\'. I use many routine and procedure. Many of them are good for this job. Here is one example:
But the problem is, when there is a folder with unicode character like 'ÆÇC¿¿examplefolderÆÇC¿¿©' inside 'C:\Windows' the result is not showed up. Only folder name like ????examplefolder???? with no files inside.
I use delphi 7 with Windows XP. Help me please, and dont tell me to use other version of Delphi. Thank you all
I want to search all files and directory recursively in a folder. example 'C:\WINDOWS\'. I use many routine and procedure. Many of them are good for this job. Here is one example:
procedure TForm1.FileSearch(const dirName: string);
var
searchResult: TSearchRec;
begin
if FindFirst(dirName + '\*', faAnyFile, searchResult) = 0 then begin
try
repeat
if (searchResult.Attr and faDirectory) = 0 then begin
if SameText(ExtractFileExt(searchResult.Name), '.gif') then begin
lbSearchResult.Items.Append(IncludeTrailingBackSlash(dirName) + searchResult.Name);
end;
end else if (searchResult.Name <> '.') and (searchResult.Name <> '..') then begin
FileSearch(IncludeTrailingBackSlash(dirName) + searchResult.Name);
end;
until FindNext(searchResult) <> 0
finally
FindClose(searchResult);
end;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
FileSearch('C:\WINDOWS');
end;
But the problem is, when there is a folder with unicode character like 'ÆÇC¿¿examplefolderÆÇC¿¿©'
I use delphi 7 with Windows XP. Help me please, and dont tell me to use other version of Delphi. Thank you all
I understand how alphabets out of Latin scope can be frustrating to deal with in programming.
Brother try to wrap foreign chars in square brackets [ ]
Waiting for your reply,
Phil.
Brother try to wrap foreign chars in square brackets [ ]
Waiting for your reply,
Phil.
Oh, I just realized that you use Delphi 7
Use an AnsiString as a data type to a declared value that holds the search parameters.
Use an AnsiString as a data type to a declared value that holds the search parameters.
Delphi provided unicode support from Delphi 2009 and upwards.you may try widestring for file name but i doubt if that would work.
ASKER
Thank you for replying guys. Finally i tried Delphi 2010. Yes it works with Unicode. But when i save the memo result to html, the unicode not fully showed. I use Firefox. Whats wrong?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
i must choose the unicode manually??
ASKER
Thanks guys :)
ASKER