strFilePathName=C:\Documents and Settings\xiagj\My Documents\Recon2009_Data.MDF;
strFilePath = Path.GetDirectoryName(strFilePathName);//这个是返回指定路径字符串的目录信息
strFileName = Path.GetFileName(strFilePathName);//这个返回指定路径的文件名和扩展名
问题是:
我输出 strFilePath = C:\Documents and Settings\xiagj
strFileName = My DocumentsRecon2009_Data.MDF
很明显不对吧,正确的答案应该是:
strFilePath = C:\Documents and Settings\xiagj\My Documents
strFileName = Recon2009_Data.MDF
谁能告诉我为什么会有这样的问题。
PS:我换成路径短的测试,得到的结果没问题,路径太长,就得到的结果有问题了。为什么???
strFilePath = Path.GetDirectoryName(strFilePathName);//这个是返回指定路径字符串的目录信息
strFileName = Path.GetFileName(strFilePathName);//这个返回指定路径的文件名和扩展名
问题是:
我输出 strFilePath = C:\Documents and Settings\xiagj
strFileName = My DocumentsRecon2009_Data.MDF
很明显不对吧,正确的答案应该是:
strFilePath = C:\Documents and Settings\xiagj\My Documents
strFileName = Recon2009_Data.MDF
谁能告诉我为什么会有这样的问题。
PS:我换成路径短的测试,得到的结果没问题,路径太长,就得到的结果有问题了。为什么???
解决方案 »
- 无聊编的一个小软件
- 随便问点东西,瞎弄。c#
- 看看这段代码
- ultraGrid合并单元格问题
- C# 写网络通信程序时如何取得协议包的byte[]字节数组呢?
- 难题如保用正则表达式取出下面内容高手们帮忙
- 新手请教,下载了一uds oa源码,在ie中打开出现如下错误
- Infragistics\NetAdvantage控件
- 为什么我用AspNetPager分页控件+datalist(留言板),分页控件只显示一页(每页8行,数据多于两页)
- emguCv 调用SetCaptureProperty(CapProp.PosFrames, Pos)出错~!
- datagridview 绑定oracle id列
- UDP 收包发包问题。。。。 为什么 客户端收不到服务器发过来的包
//引用命名空间:
using System.IO;
using System.Reflection;//获得路径
string aurl = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase.ToString()) + "\\";
http://blog.csdn.net/li0531/article/details/7781105
我敢发誓,那些错误的结果我是用console.writline()输出,然后复制到这里来的,确实是那种错误结果。
算了,不纠结了,还是自己写substring截取稳妥,怕某个时间又有错。
结贴了,谢谢大家。