Search code examples
c#.net

What is the difference between Environment.CurrentDirectory and Directory.GetCurrentDirectory?


In .NET what is the difference between:

  • Environment.CurrentDirectory
  • Directory.GetCurrentDirectory()?

Of course, Environment.CurrentDirectory is a property which can be set and obtained.

Are there any other differences?


Solution

  • As David says: they do the same thing. Internally, when getting Environment.CurrentDirectory it will call Directory.GetCurrentDirectory and when setting Environment.CurrentDirectory it will call Directory.SetCurrentDirectory.

    Just pick a favorite and go with it.