上传文件到.net core中指定的路径

uploading the file to the path specified in .netcore

我把上传的文件保存在root下。我怎样才能把这个添加到我指定的路径(@"C:\UploadsFolder")?

public JsonResult Test(FileModel model)
{
    string SavePath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/img", model.FormFile.FileName);

    using (var stream = new FileStream(SavePath, FileMode.Create))
    {
        model.FormFile.CopyTo(stream);
    }

    return Json("");
}

在FileModel.cs

public class FileModel
{
    public string Files { get; set; }

    public IFormFile FormFile { get; set; }
}

我 think.so 这应该有效,文件将上传到 C 驱动器而不是 wwroot。

string SavePath = Path.Combine(Directory.GetCurrentDirectory(), (@"C:\", model.FormFile.FileName);