我在这里有一条路径,用户可以选择他们想要的任何路径,但我需要将路径修剪成这样的
完整路径 = D:\steam\steamapps\common\Call of Duty Black Ops III\xanim_export\elfenliedtopfan5_anims\pubg\m1911
我需要从哪里开始。
elfenliedtopfan5_anims\pubg\m1911
因为我写的程序已经D:\steam\steamapps\common\Call of Duty Black Ops III\xanim_export
包含了。所以我只需要xanim_export
.
我怎样才能做到这一点?
这将为您提供使用 xanim_export\ 作为起始的子字符串。
var key = @"xanim_export\";
var path = @"D:\steam\steamapps\common\Call of Duty Black Ops III\xanim_export\elfenliedtopfan5_anims\pubg\m1911";
var keyIndex = path.IndexOf(key);
var newPath = path.Substring(keyIndex+key.Length);
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句