Mega Code Archive

 
Categories / C# / File Stream
 

Get File Name From Path

using System; using System.IO; using System.Collections.Generic; using System.Text; namespace PeDALS.Utilities {     public class FileHelper     {         public static string GetFileNameFromPath(string path)         {             string[] temp;             temp = path.Split('/');             return temp[temp.Length - 1].ToString();         }         public static string GetPathFromFileName(string path)         {             string fullPath="";             string[] temp;             temp = path.Split('\\');             for (int i = 0; i < temp.Length - 1; i++)             {                 if (i == 0)                     fullPath = temp[i].ToString();                 else                     fullPath = fullPath + "\\" + temp[i].ToString();             }             return fullPath;         }     } }