我有一個。 aspx
頁面,它在Button click
上動態創建HTML
文件。已成功創建.html
頁面,但無法使用File.Copy
方法將copy
創建的文件轉換爲destination
。使用C複製文件時出錯#
代碼背後:
protected void btnPublish_Click(object sender, EventArgs e)
{
//copy the created file content to destination
string sourcePath=string.Empty;
string destiPath = @"d://test//";
if(!string.IsNullOrEmpty(hdnPublishPath.Value))
{
sourcePath= hdnPublishPath.Value;
if (!Directory.Exists(destiPath)) // check if folde exist
{
Directory.CreateDirectory(destiPath); // create folder
//Directory.Delete(destiPath, true); // delete folder
}
File.Copy(sourcePath, destiPath,true);
}
}
它提供了異常:目錄未發現異常。 (:/ d),但文件複製失敗
目錄被提到驅動器上創建。
注:目前的路徑是「本地」,但後來這個文件將被複制到任何遠程服務器位置
把@ @ d:/ test /「'或'」d:\\ test \\「' – 2014-09-30 05:57:56