kez kez - 5 months ago 91
C# Question

Remove file path from "FilePathResult" keep only FileName.Extention

I have following code snippet

var fileResult = path as FilePathResult;

for above code snippet I'm getting long file path ,

Something like

I want to remove this
from above path and keep only

how can I do this easily


Path.GetFileName will do the trick for you as it returns the file name and extension of the specified path string.

string fileName = @"D:\Projects\Upload_Images\A.jpeg";
string result = Path.GetFileName(fileName);