Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


legal VFP file names

legal VFP file names

legal VFP file names

I want to know what the file naming convention is for VFP. I can't find it anywhere.

What characters are allowed in file names and is there is any special rule for the first character of the name?

I have VFP-compatible tables generated by another application and some of the file names begin with exclamation marks -- e.g. "!!_000_find_gk.dbf", and VFP won't recognize or open those files.


RE: legal VFP file names

There is no special convention for filenames in VFP. There are rules about what constitutes a legal filename, but these are not VFP-specific. Provided the name is legal in Windows, it will be acceptable in VFP.

Essentially, that means that the name can't contain any of the following characters:

\ / : * ? " < > |

All other characters are legal, including those from the "upper ASCII" set (such as accented letters).

There are however conventions for file extentions, such as DBF for tables and PRG for programs. Is that what you had in mind?


Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: legal VFP file names

That is not my experience.
Example -- I have a file named "!_0_tmp_R.dbf"
- this file won't open when double-clicking on it
- it won't open from a .prg file with the "USE" command
- FILE('!_0_tmp_R.dbf') shows that it exists
It always gives the error pop-up "File 'c:\mypath\.dbc' does not exist"

I haven't tried other 'unusual' characters as a first letter, but an exclamation does not work for me. Other files begin with an underscore and that works okay.

This appears to just be for naming/opening tables as a FILETOSTR command will read the file. (I haven't check database names.)

RE: legal VFP file names


The problem is with the "!" and how VFP parses it while trying to use a table: it will interpret as a separator for database!table. VFP is complaining about not finding the database container (that would have to have an empty stem name...).

You may USE ? the table from the command window, nonetheless (that is, opening it through the Open File dialog).

RE: legal VFP file names

Atlopes has found the reason, it puzzles me, that the file doesn't open with double-clicking it, though.

I can reproduce that, what works is USE ? and then picking the DBF, but using the name in any way doesn't work, neither directly nor quoted, nor as name expression nor first stored in a variable.

Many other things are allowed, like spaces, the alias name will have underscores at places the file name has spaces.

You best have file names within the rules of alias names, see "Creating Visual FoxPro Names", that also tells file names themselves only have to apply to OS rules. Aside of the Exclamation mark, it seems.

Bye, Olaf.

Olaf Doschke Software Engineering

RE: legal VFP file names

One more additional information to corroborate what we seem to have established, and another way to gain access to the table (it is, in fact, a derivation of the USE ? method).

If you manage to create a .dbc (yes, precisely that, a database container with no name) and USE "!!_000_find_gk.dbf", then VFP stops complaining about the missing .dbc, and starts to error on !_000_find_gk.dbf being not found. Notice that the first ! was skiped, and that now VFP is looking for the table.

We can have access to the table simply by inserting it into a form's DE - again, initially through the Open File dialog, but the table reference will persist in the form's definition and the table will always be available afterward.

RE: legal VFP file names

Well, if the table is free you might add it to a dbc and then the dbc internal name can be something else than the file name and you can open it via that internal name, eg like this:


Create Table !test Free (id int)
Create Database my.dbc
Add Table !test Name internalname
Use my!internalname
? Dbf() 

If the DBF already is part of a DBC you might look into the DBC what's the internal table name.

But also look into my next post, if it isn't a VFP DBF you might harm the file structure when VFP tries to embed the DBC backlink into the DBF header.

Bye, Olaf.

Olaf Doschke Software Engineering

RE: legal VFP file names

Of course the nature of that name makes me wonder, if the creator had a strong reason to only use this in conjunction with a DBC. It's not really necessary, even if a developer opens a DBF before opening its DBC, the DBC will open and for example DBC events and triggers and table and field rule and default value expressions will be taken into account.

It might of course also be a non VFP DBF type, like dBase or Clipper table. Look into the first byte of the file, that tells the DBF file type, VFP comes with HExEdit in Tools, so you can open the DBF in VFPs own Hexeditor.

See http://fox.wikis.com/wc.dll?Wiki~TableFileStructur...

Bye, Olaf.

Olaf Doschke Software Engineering

PS: Just tested this: I created a DBC with DBC events and RETURN .F. in BeforeOpenTable also prevents opening a DBF without first opening the DBC. Trying to circumvent DBC events by direct USE some.dbf doesn't work. That doesn't mean it's impossible to turn off DBC events, so I'm not saying they are a strong mean of a protection mechanism. DBC event code is "open source" and a DBC can be modified. But you don't need to fear an INSERT INTO sometable.dbf instead of INSERT INTO somedbc!sometable doesn't make use of default values stored in the DBC or doesn't know long field names. Unsure why this naming was chosen, but it might be someone found this to prevent opening a DBF standalone. It's not necessary to protect against that this way.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close