loading a file

  • Thread starter Thread starter Bill Q
  • Start date Start date
B

Bill Q

Hello,
this may not be the correct group for the post although I am using c# to
follow one of the code4fun directx tutorial. Anyway the author is
loading a texture file using the following

TextureLoader.FromFile ( _device, @"..\..\..\Resources\Left.tga"

I am not sure what the ..\..\..\ means when loading the file. I know
the directory the file lives in is C:\Documents and Settings\Bill\My
Documents\MSDN\BattleTank2005 (C#)\Resources
any help will be appreciated
thanks
bill
 
in c#
the @"filepath" say use explicite bytes in string
the // in path @ is not needed the \\ is seen as example below
filestream fs = new filestream(@"c:\xxxxxx\somefile.txt") without the @
you would get a comple error
or FileStream fs=new FileStream("c:\\xxxxx\\somfile.txt")
both examples are ok
c# sees the "\" as a internal Token

hope that helps
 
Thanks for the reply Dave. I am still confused how the .. enable the
program to drill down to the correct path where the files are stored.
thanks ]]
Bill
Dave said:
in c#
the @"filepath" say use explicite bytes in string
the // in path @ is not needed the \\ is seen as example below
filestream fs = new filestream(@"c:\xxxxxx\somefile.txt") without the @
you would get a comple error
or FileStream fs=new FileStream("c:\\xxxxx\\somfile.txt")
both examples are ok
c# sees the "\" as a internal Token

hope that helps
..
 
"..\..\..\" means "go three directories up from your application's startup
directory, then look for Resources\Left.tga"

If your application lives in

"C:\Documents and Settings\Bill\My Documents\MSDN\BattleTank2005
(C#)\Resources\Dir1\Application.exe"

then "..\..\..\" will send it to "C:\Documents and Settings\Bill\My
Documents\MSDN\BattleTank2005 (C#)"

Then it'll continue down to "Resources\Left.tga"
 
Hi,

Ashot said:
"..\..\..\" means "go three directories up from your application's startup
directory, then look for Resources\Left.tga"

If your application lives in

"C:\Documents and Settings\Bill\My Documents\MSDN\BattleTank2005
(C#)\Resources\Dir1\Application.exe"

then "..\..\..\" will send it to "C:\Documents and Settings\Bill\My
Documents\MSDN\BattleTank2005 (C#)"

Then it'll continue down to "Resources\Left.tga"

That's correct. However, using this kind of construct can be very
dangerous, especially in class libraries. For example, the application's
startup directory in ASP.NET is actually a temporary directory in which
the assemblies are cached when the application is executed. So there is
no guarantee whatsoever that the file in question will be found.

A much better alternative is to define the file's location as a user
setting in the ".config" file for example.

HTH,
Laurent
 
Laurent said:
Hi,



That's correct. However, using this kind of construct can be very
dangerous, especially in class libraries. For example, the application's
startup directory in ASP.NET is actually a temporary directory in which
the assemblies are cached when the application is executed. So there is
no guarantee whatsoever that the file in question will be found.

A much better alternative is to define the file's location as a user
setting in the ".config" file for example.

HTH,
Laurent
Thanks for the replies. I do appreciate it.
bill
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top