private uint ZipAddSettings(ZipArchive zip, Locality locality, ApplicationDataContainer root) { PrintLineFormat("Scanning {0}", locality.ToString()); var entry = zip.CreateEntry(locality.ToString() + "." + this.settingsFormat.ToString().ToLowerInvariant(), this.compressionLevel); uint countValues = 0; uint countContainers = 0; using (SettingsWriter writer = CreateSettingsWriter(entry.Open())) { WriteSettings(writer, locality, root); } return(countValues); }
private uint FileSystemAddSettings(string path, Locality locality, ApplicationDataContainer root) { PrintLineFormat("Scanning {0}", locality.ToString()); string filename = Path.Combine(path, locality.ToString() + "." + this.settingsFormat.ToString().ToLowerInvariant()); var fileStream = new FileStream(filename, FileMode.Create, FileAccess.Write, FileShare.Write | FileShare.Delete); uint countValues = 0; uint countContainers = 0; using (SettingsWriter writer = CreateSettingsWriter(fileStream)) { WriteSettings(writer, locality, root); } return(countValues); }
public string ToShortString() { var parts = new List <string>(); if (Locality != null && !string.IsNullOrWhiteSpace(Locality.ToString())) { parts.Add(Locality.ToString()); } if (AdministrativeRegion != null && !string.IsNullOrWhiteSpace(AdministrativeRegion.ToString())) { parts.Add(AdministrativeRegion.ToString()); } return(string.Join(", ", parts)); }
private uint ZipAddFolder(ZipArchive zip, Locality locality, string source) { PrintLineFormat("Scanning {0}", locality.ToString()); string parent = Path.GetDirectoryName(source); string saveCurrentDirectory = Directory.GetCurrentDirectory(); Directory.SetCurrentDirectory(parent); uint count = 0; string sourceRoot = Path.GetFileName(source); foreach (var fse in Directory.EnumerateFileSystemEntries(sourceRoot, "*", SearchOption.AllDirectories)) { string f = fse.Replace('\\', '/'); if ((File.GetAttributes(f) & System.IO.FileAttributes.Directory) != 0) { if (this.zipDirectoryEntries) { ShowProgressAddingFileSystemEntry(fse); zip.CreateEntry(f + @"/"); ++count; } } else { ShowProgressAddingFileSystemEntry(fse); zip.CreateEntryFromFile(fse, f, this.compressionLevel); ++count; } } Directory.SetCurrentDirectory(saveCurrentDirectory); if (this.displayLevel < DisplayLevel.Verbose && count > 0) { PrintLine(); } return(count); }
public override string ToString() { var parts = new List <string>(); if (Addressee != null && !string.IsNullOrWhiteSpace(Addressee.ToString())) { parts.Add(Addressee.ToString()); } if (StreetAddress != null && !string.IsNullOrWhiteSpace(StreetAddress.ToString())) { parts.Add(StreetAddress.ToString()); } if (Locality != null && !string.IsNullOrWhiteSpace(Locality.ToString())) { parts.Add(Locality.ToString()); } if (AdministrativeRegion != null && !string.IsNullOrWhiteSpace(AdministrativeRegion.ToString())) { parts.Add(AdministrativeRegion.ToString()); } if (PostalCode != null && !string.IsNullOrWhiteSpace(PostalCode.ToString())) { parts.Add(PostalCode.ToString()); } if (Country != null && !string.IsNullOrWhiteSpace(Country.ToString())) { parts.Add(Country.ToString()); } return(string.Join(", ", parts)); }
private uint FileSystemAddFolder(string path, Locality locality, string source) { PrintLineFormat("Scanning {0}", locality.ToString()); string parent = Path.GetDirectoryName(source); string saveCurrentDirectory = Directory.GetCurrentDirectory(); Directory.SetCurrentDirectory(parent); uint count = 0; string sourceRoot = Path.GetFileName(source); foreach (var fse in Directory.EnumerateFileSystemEntries(sourceRoot, "*", SearchOption.AllDirectories)) { string targetFilename = Path.Combine(path, fse); ShowProgressAddingFileSystemEntry(fse); if ((File.GetAttributes(fse) & System.IO.FileAttributes.Directory) != 0) { Directory.CreateDirectory(targetFilename); } else { File.Copy(fse, targetFilename); } ++count; } Directory.SetCurrentDirectory(saveCurrentDirectory); if (this.displayLevel < DisplayLevel.Verbose && count > 0) { PrintLine(); } return(count); }