Get help on programming - C++, Java, Delphi, etc.
Mechano
Registered User
Posts: 291 Joined: 26 Feb 2004, 02:00
Location: Cape Town
Contact:
Post
by Mechano » 08 Dec 2005, 12:04
|
[root]
|____[bin]
.....|____app.exe
.....|____app1.dll
.....|____app2.dll
|____[extras]
.....|____[archive]
.....|____[stuff]
.........|____file.txt
My problem, how do I access the file.txt from app.exe using a streamreader
StreamReader sr = new StreamReader(
What comes here? ?);
HdB
Registered User
Posts: 929 Joined: 18 Oct 2004, 02:00
Location: Bloemfontein
Contact:
Post
by HdB » 08 Dec 2005, 12:50
StreamReader sr = new StreamReader(TheFullFilePathHere);
Eg. 'c:\thedir\thefile.txt'
Or is that not what you meant? Not quite sure what you mean.
AMD Athlon 64 X2 4800+ s939 | Gecube 3870 OC edition
Mechano
Registered User
Posts: 291 Joined: 26 Feb 2004, 02:00
Location: Cape Town
Contact:
Post
by Mechano » 08 Dec 2005, 13:23
That is what I meant, but here is the problem, I can't use the Full path of the file. My app uses an installation file to install and the user can choose any directory to install his/her app into. Now, if the user doesn't install into the default directory, the path will be different.
If I want to be in the same folder as my app, i use Application.StartupPath
But in this case I want to go up one level in the dir tree and then into the extra folder...etc etc
I have to do it programmaticaly
HdB
Registered User
Posts: 929 Joined: 18 Oct 2004, 02:00
Location: Bloemfontein
Contact:
Post
by HdB » 08 Dec 2005, 13:32
So, the installation file creates this extra directory as well? Is the directory always in the same place RELATIVE to the application path?
If so, just chop of a bit of the StartupPath, using substring, and lastindexof("\"), until you have the parent folder of the extra folder.
I'm confusing myself
AMD Athlon 64 X2 4800+ s939 | Gecube 3870 OC edition
Mechano
Registered User
Posts: 291 Joined: 26 Feb 2004, 02:00
Location: Cape Town
Contact:
Post
by Mechano » 08 Dec 2005, 13:36
You might be conf yourself by it makes sense to me.
The dirs are always in the same way relative to each other. My Project Manager asked me to build the directory structure like this so now I have to make it work
HdB
Registered User
Posts: 929 Joined: 18 Oct 2004, 02:00
Location: Bloemfontein
Contact:
Post
by HdB » 08 Dec 2005, 13:44
OK, then you should just chop of a bit of the StartupPath, then add the bit of the other file's path to that, and the file name.
AMD Athlon 64 X2 4800+ s939 | Gecube 3870 OC edition
Law
Registered User
Posts: 1569 Joined: 12 Sep 2003, 02:00
Location: UND
Post
by Law » 09 Dec 2005, 07:25
just use relative adressing fool. the relative adress i think would be ../extras/stuff/file.txt
Mechano
Registered User
Posts: 291 Joined: 26 Feb 2004, 02:00
Location: Cape Town
Contact:
Post
by Mechano » 09 Dec 2005, 08:36
Whoa!!! That was just to easy....I do feel like a fool now, didn't even know about something called relative adressing up to now...
Tx dude
Law
Registered User
Posts: 1569 Joined: 12 Sep 2003, 02:00
Location: UND
Post
by Law » 09 Dec 2005, 08:51
np man. always willing to help