Archived

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

paulcoz

Embarassing question about filenames...

Recommended Posts

paulcoz    230
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 this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
if its c++, then \\ means \

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

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
you can also get the module path (in Windows) by using GetModuleNameEx()

Share this post


Link to post
Share on other sites
LeMatsch    122
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 this post


Link to post
Share on other sites
Midnight Coder    122
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 this post


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

Paulcoz.

Share this post


Link to post
Share on other sites