Google.JarResolver.PlayServicesSupport.DeleteExistingFileOrDirectory C# (CSharp) Méthode

DeleteExistingFileOrDirectory() static public méthode

Delete a file or directory if it exists.
static public DeleteExistingFileOrDirectory ( string path ) : void
path string Path to the file or directory to delete if it exists.
Résultat void
        static public void DeleteExistingFileOrDirectory(string path)
        {
            if (Directory.Exists(path))
            {
                var di = new DirectoryInfo(path);
                di.Attributes &= ~FileAttributes.ReadOnly;
                foreach (string file in Directory.GetFileSystemEntries(path))
                {
                    DeleteExistingFileOrDirectory(file);
                }
                Directory.Delete(path);
            }
            else if (File.Exists(path))
            {
                File.SetAttributes(path, File.GetAttributes(path) & ~FileAttributes.ReadOnly);
                File.Delete(path);
            }
        }