Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

File name problem (maybe char set? )

Status
Not open for further replies.

jbpelletier

Programmer
Sep 8, 2001
232
CA
Hi,

i have problems with some files name, using something like slFile.LoadFromFile (path); //slFile = stringlist

for exemple if "path" equal c:\Emu4?.ini, in my app,
Delphi will try to open c:\Emu4?.ini instead.

i realized that
fileexists('c:\Emu4?.ini') is true
but
slFile.LoadFromFile ('c:\Emu4?.ini') says that it dont exist

im reading c:\Emu4?.ini via a TSearchRec using SR.Name in a FindFirst,FindNext routine

how can i solve that??
any help would be appreciate

/* this c:\Emu4?.ini should be different from c:\Emu4?.ini in your screen */

jb
 
Do not use ? (or *) in filenames.

These are wildcard characters.

? represents a single character in a filename (and * represents one or more characters in a filename).

Typically, you will use wildcard characters in functions like FileExists and FindFirst to search for files where you can't specify the filename exactly.



Andrew
Hampshire, UK
 
I think that the ? showed up because the "real" character can't be converted. I have had that happen before.

Here is

copyright = alt + 0169 = ©
registered trademark = alt + 0174 = ®
Euro Sign = alt + 0128 = €

it usually looks right in the preview, but has a '?' in the post.

Leslie

Anything worth doing is a lot more difficult than it's worth - Unknown Induhvidual
 
Hi,

Havent found how to solve my problem, in fact as lespaul says when i "paste" the char its looks ok but when i read my post i see a '?'.

I realized that all files i have problem with are located in c:\winnt. I think those are files are for windows nt only and thats why they have invalid character (character that we can't use to create a file name).

Also i can open and edit those file via notepad but i can't open them via Delphi with function like "loadfromfile" etc..

I wish i could open them cause im building an app that scan all path located in various files / database and swap em for a new path... "migration purpose". Its possible that those file contain a path to swap...

If u have an idea how i can open em... or get the "real" name via a TSearchRec using SR.Name, i would very appreciate

tanx
Jb
 
The first thing to check is that your current system font display all characters correctly - if your getting a [tt]?[/tt] as Lesley points out then it may pay to check that (although it should map correctly as an ASCII character). Check from a command prompt what the character actually is (ie [tt]DIR c:\winnt\*.INI[/tt]) and see what is returned.

Another option is to investigate that your are retrieving the Long or Short file names (ie Windows vs DOS 8.3 format).
[tt]TSearchRec[/tt] returns in [tt]FindData[/tt] the file information in both formats (see WinSDK help : [tt]WIN32_FIND_DATA[/tt])

If thats a problem the other way you could retrieve a file list with names in long format is with a [tt]FileListBox[/tt] component - puts the whole list into a string list in its [tt]items[/tt] property. Just adjust the [tt]mask[/tt] property to what you need.

Cheers,
Chris [pc2]
 
The erroneous '?' isn't a local problem it's a Tek-Tips create the web post issue. JB, can you look in the character map, find the character and post the Keystroke info? That way we can at least see which character you're trying to show us!

leslie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top