Click here to Skip to main content
15,881,866 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Hi all,
How to get a file name and it's path through a variable using c#? How to store it in mysql database?
Thanks in advance.
Posted
Updated 24-Aug-22 14:44pm

1 solution

Dear Friend,

Get File name
string fileName = @"C:\mydir\myfile.ext";
string path = @"C:\mydir\";
string result;

result = Path.GetFileName(fileName);
Console.WriteLine("GetFileName('{0}') returns '{1}'", 
    fileName, result);

result = Path.GetFileName(path);
Console.WriteLine("GetFileName('{0}') returns '{1}'", 
    path, result);


Please refer to this link which contains the same question as yours and solved:-

how to save path of image in database using asp.net[^]


Thanks
 
Share this answer
 
v2
Comments
psgviscom 18-Feb-12 2:26am    
Thank you for your reply. But the links are not opening.
Varun Sareen 18-Feb-12 2:31am    
I am sorry dear. Actually i haven't checked the links first. Please try out this link..will be helpful

http://www.aspdotnet-suresh.com/2011/03/how-to-save-images-into-folder-and.html
psgviscom 18-Feb-12 2:36am    
Thanks.It helps me a lot.
Varun Sareen 18-Feb-12 12:44pm    
I am happy you got through :). Trying is to believing yourself that you can do :)

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