AzureSiteReplicator.Data.Site.Delete C# (CSharp) Method

Delete() public method

public Delete ( ) : void
return void
        public void Delete()
        {
            if (FileHelper.FileSystem.File.Exists(_profilePath))
            {
                FileHelper.FileSystem.File.Delete(_profilePath);
            }

            // We only really need to delete the profile.  If for
            // some reason we fail to delete the sites directory
            // that should be okay.

            try
            {
                if (FileHelper.FileSystem.Directory.Exists(_sitePath))
                {
                    FileHelper.FileSystem.Directory.Delete(_sitePath, true);
                }
            }
            catch (IOException e)
            {
                Trace.TraceError("Failed to delete sites directory: {0}", e.ToString());
            }
        }

Usage Example

        public void RemoveSite(string siteName)
        {
            HashSet <Site> sites = _sites;

            Site siteToRemove = sites.FirstOrDefault((m) =>
            {
                return(string.Equals(siteName, m.Name, StringComparison.OrdinalIgnoreCase));
            });

            if (siteToRemove != null)
            {
                siteToRemove.Delete();
                sites = new HashSet <Site>(sites);
                sites.Remove(siteToRemove);
            }

            _sites = sites;
        }