使用ASP.NET和C#获取文件名和文件路径 [英] Getting file name and file path using asp.net and c#
本文介绍了使用ASP.NET和C#获取文件名和文件路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
如何使用c#获取文件名及其通过变量的路径?如何将其存储在mysql数据库中?
预先感谢.
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.
推荐答案
亲爱的朋友,
获取文件名
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);
请参考此链接,其中包含与您相同的问题并已解决:-
如何在数据库中保存图像路径使用asp.net [ ^ ]
谢谢
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
这篇关于使用ASP.NET和C#获取文件名和文件路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文