从完整的目录路径删除一个目录 [英] Remove one directory from full directory path
本文介绍了从完整的目录路径删除一个目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的C目录路径:\Subdir1\Subdir2\Subdir3\filename.xml
我需要首先检查文件, filename.xml中
在Subdir2
的根目录中在寻找Subdir3
之前(一级背面)。我怎么能与伊斯利 Path.GetPathRoot解析这个(文件名)
?
即
首先看是否是真实的:
C:\Subdir1\Subdir2\filename.xml
块引用>
如果并非如此,那么默认为
C:\Subdir1\SubDir2\Subdir3\filename的.xml
该文件。
解决方案Directory.GetParent (DIR).FullName
I have a directory path of
C:\Subdir1\Subdir2\Subdir3\filename.xml
.I need to first check if the file,
filename.xml
exists in the root of"Subdir2"
(one level back) before looking in"Subdir3"
. How can I easly parse this withPath.GetPathRoot(filename)
?I.E.
First see if this is true:
C:\Subdir1\Subdir2\filename.xml
If not true, then default to
C:\Subdir1\SubDir2\Subdir3\filename.xml
for the file.解决方案Directory.GetParent(dir).FullName
这篇关于从完整的目录路径删除一个目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文