private FileStream OpenFileStreamInStorage(object id, string filename)
        {
            var metadata = new FileStorageMetadata
            {
                Id         = id,
                Filename   = filename,
                UploadDate = DateTime.Now,
            };

            WriteMetadataToXml(metadata);
            return(new FileStream(Path.Combine(_ct.storagePath, $"{id}.bin"), FileMode.Create, FileAccess.Write));
        }
        private void CopyFileToStorage(object id, string source)
        {
            var metadata = new FileStorageMetadata
            {
                Id         = id,
                Filename   = Path.GetFileName(source),
                UploadDate = DateTime.Now,
            };

            File.Copy(source, Path.Combine(_ct.storagePath, $"{id}.bin"), true);
            WriteMetadataToXml(metadata);
        }
 private void WriteMetadataToXml(FileStorageMetadata metadata)
 {
     using var writer = new StreamWriter(Path.Combine(_ct.storageMetadataPath, $"{metadata.Id}.xml"));
     serializer.Serialize(writer, metadata);
 }