Asp.Net:在路径位置保存文件

时间:2012-06-19 11:35:51

标签: c# asp.net

我在客户端上传了pdf文件。

我将路径位置传递给.ashx file,从此我在字符串变量中有路径位置。我需要将该文件保存在该路径位置。

请帮忙。

1 个答案:

答案 0 :(得分:0)

假设rootPath是包含根路径的变量,fileName是您要保存的文件的名称:

var filePath = System.IO.Path.Combine(rootPath, fileName);

我不知道该文件的格式是什么。如果包含该文件,我可以从那里更好地说明如何处理filePath

using (var outputStream = File.Open(filePath, FileMode.CreateNew))
{
    // write to outputStream; depends on what form your PDF file is in at this point.
}