Open weird filenames

Hello,

I'm trying to open file, that FindNext routine returned. The filename is 'T_-جÍ7-11¬ÝTW¦ñ.txt' and when I try TFileStream.Create, it throws an exception "Can't find file specified". However, the file is phisically exists and I can access it through Windows Explorer.

Thanks
iam_dumbAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

calinutzCommented:
It's because of the weird chars that are contained by the file name.  I think that the problem is mainly in the '|' character.
Did you try to change the filename from explorer to see if it gives you an error? The explorer sees the file but I am not sure that it can manipulate it.
The file was probabely made using some localised windows in China, Russia or something like that.
pcsentinelCommented:
Dont know if this will help, no way of testing at the moment, but say you've got a find function something like

var
  lix      : word;
  lSrchRec : TSearchRec;
  lSdName  : string ;
begin
  Result:=True;
  if Directory[Length(Directory)]<>'\' then AppendStr(Directory,'\');
  lix:=FindFirst(Directory+'*.*',faAnyFile,lSrchRec);
  while lix=0 do
  begin
    lSdName := lSrchRec.Name ;
    if ((lSrchRec.Attr AND faDirectory)>0) AND (lSdName<>'.') AND (lSdName<>'..') then
      strDirs.Add(Directory+lSdName);
    lix:=FindNext(lSrchRec);
  end;
  FindClose(lSrchRec);
end;

try changing lSdName  from a string to a widestring, what is the name of the file now?

as I say this is pure guesswork

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.