C# get filename and extension

string fullPath = @"d:\test\default.avi";


string filename = Path.GetFileName (fullPath); //return the filename with extension "default.avi"
string extension = Path.GetExtension (fullPath);//extension ".aspx"
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension (fullPath );// The file name without extension "default"


string dirPath = Path.GetDirectoryName(filePath) //return the directory where the file is located "d:\test"
string fullPath1 = Path. Combine (@"d:\test", " default.avi") //return "d:\test\default.avi"

string fullPath2 = Path.GetFullPath("config.ini");//return the absolute path of the specified path string

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=324131948&siteId=291194637