By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,107 Members | 1,245 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,107 IT Pros & Developers. It's quick & easy.

loading a file

P: n/a
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
Feb 22 '07 #1
Share this Question
Share on Google+
5 Replies


P: n/a
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

"Bill Q" <bi********@comcast.netwrote in message
news:oP******************************@comcast.com. ..
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

Feb 22 '07 #2

P: n/a
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 P wrote:
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

"Bill Q" <bi********@comcast.netwrote in message
news:oP******************************@comcast.com. ..
>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

..
Feb 23 '07 #3

P: n/a
"..\..\..\" 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"

"Bill Q" <bi********@comcast.netwrote in message
news:oP******************************@comcast.com. ..
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

Feb 23 '07 #4

P: n/a
Hi,

Ashot Geodakov wrote:
"..\..\..\" 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 Bugnion [MVP ASP.NET]
Software engineering, Blog: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Feb 23 '07 #5

P: n/a
Laurent Bugnion [MVP] wrote:
Hi,

Ashot Geodakov wrote:
>"..\..\..\" 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
Thanks for the replies. I do appreciate it.
bill
Feb 23 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.