Archived

This topic is now archived and is closed to further replies.

Embarassing question about filenames...

This topic is 5977 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

I've always stored the required files in my program like textures etc.. in the one folder (the same folder as the executable). I now want to move the files to sub-folders like textures\texture.bmp or maps\level1.map for organisational purposes. As far as I can tell you can't refer to a sub-folder by specifying the name as 'textures\level1.map' or \textures\level1.map'. In fact, I think single back-slashes might even be illegal in paths! - at the moment I have to use the whole path from the root directory with double-backslashes eg. '\\program folder\\textures\\level1.map' to get it to work. Is this normal (if it is I can live with it!!), or can you refer to files within sub-folders of the folder you run the program from, more easily? If so, how? Paulcoz. Edited by - paulcoz on August 1, 2001 3:53:03 AM

Share on other sites
if its c++, then \\ means \

just use \\ with that same thing like "\\textures\\level1.map" or "textures\\level1.map"

Share on other sites
you can also get the module path (in Windows) by using GetModuleNameEx()

Share on other sites
the backslash is used for all kind of special characters...
you probably used them yourself. \n is the most common.
now if you string contains "\textures" then the compiler would think \t is one of these special characters.
\\ will be interpreted as a single \ by the compiler.

however (!) the \\ will not be stored in memory...
there''s going to be the single one
the backslash + character combination is just a convinience for programmers
if you type the texture-names in a txt-file and read them with your programm then you won''t use the double \\

nik

Share on other sites
Use forward slash

"textures/texture.bmp"
"sounds/blah.wav"
"somedir/somefile.abc"
etc.

Simple.

Share on other sites
If you make a string in your program, then just use ''\\''. It means the exact same thing and it is the only way to get the compiler to interpret a single backslash. Backslashes in files and backslashes typed in the keyboard are interpreted normally. Meaning if you make a text file for your program to read, you would use a single backslash in the file. Also, if you just specify something like ''textures\level1.map'', it will use the current working directory for the beginning of the path. This is usually not desired, because the working directory can be changed.

Share on other sites
I don''t know what I was doing wrong before (when referencing the sub-folders) - everything seems to be working now, thankyou.

Paulcoz.

• Forum Statistics

• Total Topics
628681
• Total Posts
2984188

• 13
• 12
• 9
• 10
• 10