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 with Path.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.
To remove a directory and all its contents, including any subdirectories and files, use the rm command with the recursive option, -r . Directories that are removed with the rmdir command cannot be recovered, nor can directories and their contents removed with the rm -r command.
How to Remove a Directory in Linux. To permanently remove a directory in Linux, use either rmdir or rm command: For empty directories, use rmdir [dirname] or rm -d [dirname] For non-empty directories, use rm -r [dirname]
To remove a directory that is not empty, use the rm command with the -r option for recursive deletion. Be very careful with this command, because using the rm -r command will delete not only everything in the named directory, but also everything in its subdirectories.
Directory.GetParent(dir).FullName
Try this one Directory.GetParent
and System.IO.File.Exists
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With