VB CurDir() what is C# function

D

Dave

In VB .Net I can get the current directory using the
CurDir() function. Does C# have a similar function. Or
how can I discover the current path in C#?
 
D

Dennis

Try the code segments below. You can grab other
information out of the "Application" object as well.
I hope this answers your question.


Dennis Vansickle
-----Original Message-----
In VB .Net I can get the current directory using the
CurDir() function. Does C# have a similar function.

string str = String.Empty;
System.IO.DirectoryInfo curPath;
System.IO.FileInfo[] fis;
System.IO.DirectoryInfo[] dis;

curPath = new System.IO.DirectoryInfo
(Application.StartupPath);
dis = curPath.GetDirectories();
fis = curPath.GetFiles();

foreach (System.IO.DirectoryInfo di in dis)
str += di.Name + "\n";

foreach (System.IO.FileInfo fi in fis)
str += fi.Name + "\n";

MessageBox.Show(str);

Or how can I discover the current path in C#?
.

MessageBox.Show("Current Path = " +
Application.StartupPath);
 
J

Jyothi Srinivasan [MS]

Hi,
In C#, you can use System.Environment.CurrentDirectory which gets the
fully qualified path of the current directory.

Regards,
Jyothi

--------------------

|
| Try the code segments below. You can grab other
| information out of the "Application" object as well.
| I hope this answers your question.
|
|
| Dennis Vansickle
|
| >-----Original Message-----
| >In VB .Net I can get the current directory using the
| >CurDir() function. Does C# have a similar function.
|
| string str = String.Empty;
| System.IO.DirectoryInfo curPath;
| System.IO.FileInfo[] fis;
| System.IO.DirectoryInfo[] dis;
|
| curPath = new System.IO.DirectoryInfo
| (Application.StartupPath);
| dis = curPath.GetDirectories();
| fis = curPath.GetFiles();
|
| foreach (System.IO.DirectoryInfo di in dis)
| str += di.Name + "\n";
|
| foreach (System.IO.FileInfo fi in fis)
| str += fi.Name + "\n";
|
| MessageBox.Show(str);
|
|
| > Or how can I discover the current path in C#?
| >.
|
| MessageBox.Show("Current Path = " +
| Application.StartupPath);
|
|
 

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

Similar Threads


Top