Archived

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

Chacha

Simple file loading question

Recommended Posts

Chacha    138
How would I go about loading/using files that are in a different directory than my program executable? Eg: I have a main game folder with the executable, and this program needs to load files (eg: bitmaps) from another directory, which is located in the folder "Graphics". How would I go about this? Any help would be great (btw, I''m using C++)

Share this post


Link to post
Share on other sites
Lektrix    106
Use "..\" to go up a level, and you use the folder name, for example "Graphics\" to go into directories. Or you can use the full path, for example "C:\Blah\Bleh\Blergh.bmp", but you shouldn't use this, unless you are sure of the path, if you intend on using the program on different machines, as where the executable is placed could differ.

[ Google || Start Here || ACCU || MSDN || STL || GameCoding || BarrysWorld || E-Mail Me ]

[edited by - Lektrix on May 28, 2003 7:11:05 AM]

Share this post


Link to post
Share on other sites
Chacha    138
Hey thanks, but I can''t seem to get it working...
Maybe I didn''t understand you, this is what I''ve done:

LoadSomething("..\Graphics\example.bmp");

Please, how exactly does the syntax look like?

Share this post


Link to post
Share on other sites
Chacha    138
Thanks guys, got it working

Just one more thing (and I hope I don''t sound too picky),
but I noticed that the backslash (\) didn''t work when writing to directories, but the foward slash (/) does work.

Lektrix, did you just make a mistake by using back slashes instead of foward slashes??

Anyway I know it doesn''t matter and you probably just mixed ''em up... Thanks again.

Share this post


Link to post
Share on other sites
Lektrix    106
quote:
Original post by chacha8
Lektrix, did you just make a mistake by using back slashes instead of foward slashes??

Oops. That should be "\\", as in:

LoadSomething("Graphics\\graphic.bmp");

Bleh, escape sequences. But yeah, forward slash will work as well, although I like to use back slashes for files.

[ Google || Start Here || ACCU || MSDN || STL || GameCoding || BarrysWorld || E-Mail Me ]

[edited by - Lektrix on May 28, 2003 9:58:13 AM]

Share this post


Link to post
Share on other sites
randomZ    163
I think it depends on the compiler you use. Mingw32/gcc, coming from the *nix world, takes forward slashes ''/''. I don''t know about vc++ or other compilers.

A single backslash will of course escape the next character and therefore not work.

I always use forward slashes, in a desperate attempt to keep things portable


My Wonderful Web Site (C++ SDL OpenGL Game Programming)

I am a signature virus. Please add me to your signature so that I may multiply.

Share this post


Link to post
Share on other sites