|
-
Sep 19th, 2006, 10:31 AM
#1
Thread Starter
New Member
[RESOLVED] [02/03] Obtaining the current directory
What are the differences between the following methods for obtaining the current directory:-
-Application.StartupPath
-Environment.CurrentDirectory
-AppDomain.CurrentDomain.BaseDirectory
Are there any advantages to each? Does the application you are developing (win form, service, dll etc) dictate the method that should be used?
Regards,
-
Sep 19th, 2006, 10:49 AM
#2
-
Sep 19th, 2006, 10:54 AM
#3
Re: [02/03] Obtaining the current directory
Environment.CurrentDirectory is the only one that is not read only. It can be assigned a value.
-
Sep 19th, 2006, 07:11 PM
#4
Re: [02/03] Obtaining the current directory
Application.StartupPath and Environment.CurrentDirectory may contain the same path on many occasions but they are quite different. Application.StartupPath is the folder from which your EXE was run. It is always that path, no matter where that path may be, and it cannot be changed during a session. Environment.CurrentDirectory is the current working directory for the application. It will initially be the same as Application.StartupPath by default but it doesn't have to be. If you run an application from a shortcut and the "Start in:" field is set then that's what the initial value of Environment.CurrentDirectory will be. If you start a process using Process.Start and you set the WorkingDirectory property of its ProcessStartInfo then that's what the initial value of Environment.CurrentDirectory will be. Environment.CurrentDirectory can also be changed in many other ways, e.g. navigating to different folders in an OpenFileDialog or SaveFileDialog with its RestoreDirectory property set to False.
-
Oct 2nd, 2006, 11:28 AM
#5
Thread Starter
New Member
Re: [02/03] Obtaining the current directory
Ok thanks for all the help
-
Oct 2nd, 2006, 07:19 PM
#6
Re: [02/03] Obtaining the current directory
Don't forget to resolve your thread from the Thread Tools menu if you have a satisfactory answer.
-
Oct 4th, 2006, 11:53 AM
#7
Frenzied Member
Re: [RESOLVED] [02/03] Obtaining the current directory
Thanks Guys.
Code:
Dim path As String
path = Application.StartupPath & "\CodeRed_1_0_0_6\" & "CodeRed.exe.config.deploy"
fileMap.ExeConfigFilename = path
Steve
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
|