Click here to Skip to main content
15,894,539 members
Please Sign up or sign in to vote.
1.33/5 (2 votes)
See more:
hi ,
how to get file name from url, suggest me
Posted

if you use FileUpload control,
<asp:FileUpload ID="fileTest" runat="server" />


Use Path.GetFileName Method
System.IO.Path.GetFileName(fileTest.FileName)
 
Share this answer
 
HEllo


Uri uri = new Uri(hreflink);
string filename = Path.GetFileName(uri.LocalPath);

Hope it works





Thanks
Abhimanyu Rawat
 
Share this answer
 
Comments
Baroor 22-Jul-14 6:16am    
EX: C://Parent Filder/Child Folder/file.
By using above method im getting only "C://Parent Filder/Child Folder".
not getting file name.
other way without to use FileUpload control,


C#
String URL = "http://localhost:62527/xxxxxxx/yyyyyyy.aspx";
            System.Uri uri = new System.Uri(URL);
            string[] segments = uri.Segments;
            int l=segments.Length;
            string filetest = segments[l-1];


Hope it works
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900