How can I get the directory name???

  • Thread starter Thread starter Ricardo
  • Start date Start date
R

Ricardo

How can I get the directory name that the aplication is being executed???

[]s...
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top