コード例 #1
0
        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));
        }
コード例 #2
0
        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);
        }
コード例 #3
0
 private void WriteMetadataToXml(FileStorageMetadata metadata)
 {
     using var writer = new StreamWriter(Path.Combine(_ct.storageMetadataPath, $"{metadata.Id}.xml"));
     serializer.Serialize(writer, metadata);
 }