C#相对路径问题,如何得到一个路径相对别一个路径的相对路径 例如:path1="c:\a"path2="c:\a\b\c\t.txt" 相对path1的路径应该为"\b\c\t.txt"path3="c:\a\b\c\" 相对path1的路径应该为"\b\c"怎么样能方便的获得path2和path3相对path1的相对路径呢? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 public string GetPath(string p1,string p2){ if(p1.length > p2.length) { return p1.Replace(p2,""); } else if(p1.length < p2.length) { return p2.Replace(p1,""); } else //p1==p2 { return "";//or return p1; }} public string GetPath(string p1, string p2) { int iIdx = p1.IndexOf(p2); int iIdy = p2.IndexOf(p1); if (iIdx != -1 || iIdy != -1) { if (p1.Length > p2.Length) { return p1.Replace(p2, ""); } else if (p1.Length < p2.Length) { return p2.Replace(p1, ""); } else //p1==p2 { return "";//or return p1; } } else { return ""; } } 数据采集问题 批量更换CSS样式(急) appface使用问题 using System.Management 网络异步传输问题~~大哥们进来帮忙啊~[解决即给分] vss 配置虚服务器时 请问在.Net中如何把图像中的像素信息(RGB颜色信息)存在数组中阿? 请问如何使用 多个压缩工具 进行 高级压缩????????????? 关于文件下载 c#后台如何获取在word中复制的表格内容 大家帮忙想一个好的例子 c# 开发socket 用 SocketAsyncEventArgs
public string GetPath(string p1,string p2)
{
if(p1.length > p2.length)
{
return p1.Replace(p2,"");
}
else if(p1.length < p2.length)
{
return p2.Replace(p1,"");
}
else //p1==p2
{
return "";//or return p1;
}
}
{
int iIdx = p1.IndexOf(p2);
int iIdy = p2.IndexOf(p1); if (iIdx != -1 || iIdy != -1)
{
if (p1.Length > p2.Length)
{
return p1.Replace(p2, "");
}
else if (p1.Length < p2.Length)
{
return p2.Replace(p1, "");
}
else //p1==p2
{
return "";//or return p1;
}
}
else
{
return "";
} }