CSharp examples for File IO:Path
Manipulate Strings Representing File Names
using System;//from w w w . j a v a 2s.c om using System.IO; static class MainClass { static void Main(string[] args) { string filename; filename = @"..\System\MyFile.txt"; filename = Path.GetFileName(filename); Console.WriteLine(filename); filename = @"..\..\myfile.txt"; string fullPath = @"c:\Temp"; filename = Path.GetFileName(filename); fullPath = Path.Combine(fullPath, filename); Console.WriteLine(fullPath); Console.WriteLine(filename); // (fullPath is now "c:\Temp\myfile.txt") } }