private StandaloneMetadataStore LoadMetadataStore() { if (!File.Exists(_metadataPath)) { return(CreateStandaloneMetadataStore()); } using (var fileStream = new FileStream(_metadataPath, FileMode.Open, FileAccess.Read, FileShare.None, BufferSize, true)) { return(StandaloneMetadataStore.ReadFromStream(fileStream)); } }
private void SetPropertiesImplementation() { using (var fileStream = new FileStream(_metadataPath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None, BufferSize, true)) { var metadataStore = fileStream.Length == 0 ? CreateStandaloneMetadataStore() : StandaloneMetadataStore.ReadFromStream(fileStream); metadataStore.ContentType = _properties.ContentType; fileStream.SetLength(0); metadataStore.WriteToStreamAndClose(fileStream); } }
private void SetMetadataImplementation() { using (var fileStream = new FileStream(_metadataPath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None, BufferSize, true)) { var metadataStore = fileStream.Length == 0 ? CreateStandaloneMetadataStore() : StandaloneMetadataStore.ReadFromStream(fileStream); foreach (var key in _metadata.Keys) { metadataStore.Metadata[key] = _metadata[key]; } fileStream.SetLength(0); metadataStore.WriteToStreamAndClose(fileStream); } }