图片路径 Book_Net/2009/9/15/20099159845.jpg我想得到20099159845.jpg请大家帮帮我。 我上传图片是遇到了这个问题,就是 从图片路径中的得到目录路径和图片名称 如:图片路径 Book_Net/2009/9/15/20099159845.jpg我想得到分别得到Book_Net/2009/9/15/ 和 20099159845.jpg 谢谢。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 string fileName = System.IO.Path.GetFileName(@"Book_Net/2009/9/15/20099159845.jpg");string path = System.IO.Path.GetDirectoryName(@"Book_Net/2009/9/15/20099159845.jpg"); string xx = "Book_Net/2009/9/15/20099159845.jpg"; string newPath = xx.Substring(0,xx.LastIndexOf('/')+1); string newFileName = xx.Substring(xx.LastIndexOf('/')+1); MessageBox.Show(newPath.ToString()); MessageBox.Show(newFileName.ToString()); string filename = filename.Substring(filename.LastIndexOf("/") + 1);string filepath = Server.MapPath("Book_Net/2009/9/15"); 要引用System.IO命名空间System.IO.Path.GetFileName取文件名,比如"C:\new\1.txt",结果为"1.txt"System.IO.Path.GetDirectoryName取路径,比如"C:\new\1.txt",结果为"C:\new" Book_Net/2009/9/15 还是得不到啊? GetDirectoryName方法只是取路经,因为你的15是最后的文件夹,所以取出来是上面的.你可以手工加个\ string fileName = System.IO.Path.GetFileName(@"Book_Net/2009/9/15/20099159845.jpg");string path = System.IO.Path.GetDirectoryName(@"Book_Net/2009/9/15/20099159845.jpg"); 用DetailView绑定数据,编辑和新增问题 TabContainer 动态添加 TabPanel 问题?求救高手 我该在【什么地方加插入数据库】的处理代码?怎么写? .net数据库的问题! javascript的的问题。 大家多多帮忙测下! 同样的程序,不一样的结果,高手给小弟指点一下. 谢谢了 周末散分,心情郁闷,希望能过个轻松的周末,也祝大家周末愉快! 下载文件的文件名问题 怎么写服务器控件的客户端事件阿? 1000M的空间,500M的SQL数据库能容纳多少人同时在线? .net如何使用ASP的SET?
string path = System.IO.Path.GetDirectoryName(@"Book_Net/2009/9/15/20099159845.jpg");
string xx = "Book_Net/2009/9/15/20099159845.jpg";
string newPath = xx.Substring(0,xx.LastIndexOf('/')+1);
string newFileName = xx.Substring(xx.LastIndexOf('/')+1);
MessageBox.Show(newPath.ToString());
MessageBox.Show(newFileName.ToString());
string filename = filename.Substring(filename.LastIndexOf("/") + 1);
string filepath = Server.MapPath("Book_Net/2009/9/15");
System.IO.Path.GetFileName取文件名,比如"C:\new\1.txt",结果为"1.txt"
System.IO.Path.GetDirectoryName取路径,比如"C:\new\1.txt",结果为"C:\new"
你可以手工加个\
string path = System.IO.Path.GetDirectoryName(@"Book_Net/2009/9/15/20099159845.jpg");