VB CurDir() what is C# function

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dave

    #1

    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#?
  • Dennis

    #2
    VB CurDir() what is C# function

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


    Dennis Vansickle
    [color=blue]
    >-----Original Message-----
    >In VB .Net I can get the current directory using the
    >CurDir() function. Does C# have a similar function.[/color]

    string str = String.Empty;
    System.IO.Direc toryInfo curPath;
    System.IO.FileI nfo[] fis;
    System.IO.Direc toryInfo[] dis;

    curPath = new System.IO.Direc toryInfo
    (Application.St artupPath);
    dis = curPath.GetDire ctories();
    fis = curPath.GetFile s();

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

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

    MessageBox.Show (str);

    [color=blue]
    > Or how can I discover the current path in C#?
    >.[/color]

    MessageBox.Show ("Current Path = " +
    Application.Sta rtupPath);

    Comment

    • Jyothi Srinivasan [MS]

      #3
      RE: VB CurDir() what is C# function


      Hi,
      In C#, you can use System.Environm ent.CurrentDire ctory 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 "Applicatio n" 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.Direc toryInfo curPath;
      | System.IO.FileI nfo[] fis;
      | System.IO.Direc toryInfo[] dis;
      |
      | curPath = new System.IO.Direc toryInfo
      | (Application.St artupPath);
      | dis = curPath.GetDire ctories();
      | fis = curPath.GetFile s();
      |
      | foreach (System.IO.Dire ctoryInfo di in dis)
      | str += di.Name + "\n";
      |
      | foreach (System.IO.File Info 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.Sta rtupPath);
      |
      |

      Comment

      Working...