|
-
Aug 20th, 2004, 04:36 AM
#1
Thread Starter
Member
file path?
Hi all,
I want to be able to use a file (.gif) without knowing exactly where it's located.
If I put the file in the same directory as my .sln file how can I access the file?
In vb6 there is something like app.path to get the directory where project files are.
is there a function that takes a file (for example .sln my file) and return the full path so I can use that if I put the .gif file in the same dir as my .sln file ?
Regards
Jonni
-
Aug 20th, 2004, 05:28 AM
#2
Fanatic Member
just put it in the project folder/bin/debug and access it as
Code:
Application.StartUpPath+@"\file.extension"
-
Aug 21st, 2004, 12:01 AM
#3
Sleep mode
My 2cent :
It would be a lot safer to use Combine the two paths using this method .
PHP Code:
using System.IO
string path=Path.Combine(Application.StartupPath,"file.extension")
-
Jan 13th, 2006, 12:18 PM
#4
Fanatic Member
Re: file path?
Hello,
I'm using the VS.Net and it doesn't work...
did the code change?
I want to get the path of the project...
anyone knows how?
thanks
-
Jan 13th, 2006, 12:29 PM
#5
Re: file path?
Try
Code:
string aPath1 = Application.ExecutablePath;
string aPath2 = Application.StartupPath;
-
Jan 13th, 2006, 05:23 PM
#6
Fanatic Member
Re: file path?
why can't it recognise the "Application.ExecutablePath" and
"Application.StartupPath" functions?
or am I doing something wrong?
I have a dll that I'm building, and I want to save some preferences in a txt
file in the same folder...
-
Jan 13th, 2006, 07:38 PM
#7
Sleep mode
Re: file path?
Application Class comes under this namespace "System.Windows.Forms".
-
Jan 13th, 2006, 08:43 PM
#8
Re: file path?
If you've created a Class Library project, as it would seem you have, then you will need to add a reference to the System.Windows.Forms assembly, which contains the System.Windows.Forms namespace. If you want to create a DLL with WinForms functionality you can create a Windows Control Library project from the start, which already has that reference.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|