Argentini.Halide.H3Storage.DeleteDirectory C# (CSharp) Метод

DeleteDirectory() публичный статический Метод

Deletes a directory, and any files and subdirectories it contains. Directory passed is in standard web form (e.g. "/temp").
public static DeleteDirectory ( string directory ) : String
directory string Directory to delete (as "/temp"). Passing an empty string will delete the current working directory!
Результат String
        public static String DeleteDirectory(string directory)
        {
            if (H3Text.FixNull(directory).ToString().Length < 1)
            {
                return ("You did not specify a directory to delete.");
            }
            else
            {
                try
                {
                    string webdir = H3Storage.MapPath(directory);

                    string dirObject = String.Format("win32_Directory.Name='{0}'", webdir);

                    using (ManagementObject dir = new ManagementObject(dirObject))
                    {
                        dir.Get();
                        ManagementBaseObject outParams = dir.InvokeMethod("Delete", null, null);
                    }
                }

                catch(DirectoryNotFoundException)
                {
                    return ("The directory \"" + directory + "\" does not exist.");
                }

                catch(PathTooLongException)
                {
                    return ("The directory \"" + directory.ToString().Substring(1, 80) + "...\" is too long and exceeds the system-defined maximum length for a directory name.");
                }

                catch(Exception e)
                {
                    return ("Cannot delete the directory due to the following exception:<pre>\r\n" + e + "<pre>");
                }

                return (string.Empty);
            }
        }