473,387 Members | 1,575 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

VB CurDir() what is C# function

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#?
Jul 21 '05 #1
2 7965
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);

Jul 21 '05 #2

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);
|
|

Jul 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: domeceo | last post by:
can anyone tell me why I cannot pass values in a setTimeout function whenever I use this function it says "menu is undefined" after th alert. function imgOff(menu, num) { if (document.images) {...
5
by: phil_gg04 | last post by:
Dear Javascript Experts, Opera seems to have different ideas about the visibility of Javascript functions than other browsers. For example, if I have this code: if (1==2) { function...
1
by: Lance | last post by:
Hi All, I change the current directory in a proc, using CurDir(). The change persists across executions. I would like the CurDir() return value to be the same at the start of each execution. Any...
2
by: laredotornado | last post by:
Hello, I am looking for a cross-browser way (Firefox 1+, IE 5.5+) to have my Javascript function execute from the BODY's "onload" method, but if there is already an onload method defined, I would...
6
by: Ian | last post by:
Can someone tell me what CurDir returns, I am trying to find the path to the Drive letter where Windows is installed on a PC, using code like: Function DriveLetter() Dim curdrv As String ...
2
by: sushil | last post by:
+1 #include<stdio.h> +2 #include <stdlib.h> +3 typedef struct +4 { +5 unsigned int PID; +6 unsigned int CID; +7 } T_ID; +8 +9 typedef unsigned int (*T_HANDLER)(void); +10
1
by: RAJ | last post by:
Hi, I am acccessing my crystal reports bundled version developed in VB.NET 2002. I stored my report in local C drive and set the report source as follows: rptPositiveMatch.ReportSource =...
2
by: Dave | last post by:
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#?
0
by: Renatebhp | last post by:
While using CurDir to get the current path where my open workbook is located, I get a result that's short of the current folder.e.g. the path to the file is...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.