How can i delete a directory having subdirectory inside it which is not empty.
thanks for the answers
but now when am deleteing any directory at run time so it will take me to the login page.
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.
In Linux, whenever you want to delete a file, you'd use the rm command. When it comes to deleting a directory, however, things get a bit complex. To delete a directory, there's a dedicated tool rmdir that can remove empty directories.
rm command with -f , force option combined with -r as rm -rf option is used to force remove Linux directories. -r stands for recursive so that rm can remove all the sub-directories also. -r option is needed to remove a directory even if the directory is empty with no subdirectory or file in it.
There are two ways to remove directories in Linux: the rm and rmdir commands. The TL;DR of both commands is that rm deletes directories that may contain content such as files and subdirectories, while rmdir ONLY deletes empty directories.
You could use the Directory.Delete method passing true
as second argument.
Directory.Delete(@"c:\somedirectory", true);
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