How can I get the directory name???

  • Thread starter Thread starter Ricardo
  • Start date Start date
For Windows Forms applications, you can use the read-only static property System.Windows.Forms.Application.StartupPath

Another option is to use the static method System.IO.Directory.GetCurrentDirectory(). This returns the current working directory, which isn't necessarily the application path. However, you can call this method immediately after launching the application and store the return value in a variable to preserve the original application path.

I hope this helps.
 
Look into the Application class. There are many static properties off of
this object. The one you are looking for is Application.StartupPath I
believe. There is also the ExecutablePath property that might be of some
use to you.

C Addison Ritchie, MCSD.NET
Ritch Consulting, Inc.
 
Ricardo said:
How can I get the directory name that the aplication is being executed???

[]s...
Hi Ricardo,

try

using System.IO;
using System.Reflection;

[...]

System.Diagnostics.Debug.WriteLine(
Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));

Cheers

Arne Janning
 
Back
Top