Search
Close this search box.

File path in C#

When you have to pass in a file path to do some processing with the file, try using the following C# code.

string path = Path.Combine(Environment.CurrentDirectory, @"..\..\TestDeserialization.xml");

Where,

The TestDeserialization.xml file is in the Project root directory.

It helps to avoid confusion in file paths.

This article is part of the GWB Archives. Original Author: Vinayak

Related Posts