MVC を使用して最小限のアクセスでサーバー上のファイルを記録する方法。コードの次のバージョンは、ドメインを詰まらせるため、適切ではありません。
コントローラーコード:
var fileFile = Request.Files["p" + prop.Id];
if (fileFile == null) continue;
string pathFile = AppDomain.CurrentDomain.BaseDirectory + "UploadedFiles";
string filenameFile = Path.GetFileName(fileFile.FileName);
if (filenameFile != null) fileFile.SaveAs(Path.Combine(pathFile, filenameFile));
(ファイルをキャッシュに入れることでこれを実現できる場合)
編集されたコード:
var normalPropertyValue = new Catalog.Core.Entities.OrdinaryPropertyValue();
Environment.CurrentDirectory = Environment.GetEnvironmentVariable("TEMP");
var fileFile = Request.Files["ファイル" + prop.Id]; if (fileFile == null) 続行;
文字列 pathFile = Environment.CurrentDirectory;
fileFile.SaveAs(pathFile);
通常のPropertyValue.Value = pathFile;
instance.SetPropertyValue(prop.Id, 通常のPropertyValue);