Work with Relative Paths - CSharp File IO

CSharp examples for File IO:Path

Description

Work with Relative Paths

Demo Code


using System;/*www  .  ja va2s .  co m*/
using System.IO;

    static class MainClass
    {
        static void Main()
        {
            Console.WriteLine("Using: " + Directory.GetCurrentDirectory());
            Console.WriteLine("The relative path 'file.txt' " + "will automatically become: '" + Path.GetFullPath("file.txt") + "'");

            Console.WriteLine("Changing current directory to c:\\");
            Directory.SetCurrentDirectory(@"c:\");

            Console.WriteLine("Now the relative path 'file.txt' " + "will automatically become '" + Path.GetFullPath("file.txt") + "'");

        }
    }

Result


Related Tutorials