2013-07-24 34 views
0

我試圖做一些非常簡單的事情,但需要花費更長時間才能弄清楚它應該如何。File.copy爲什麼不能使用Server.MapPath

所以我有工作其中源文件和目標都是字符串值這個副本的方法。

硬編碼值工作

Dim copyPath As String ="C:\inetpub\wwwroot\somesite.com\someFolder\dink1\muffin.gif" 
Dim copyPath2 As String = C:\inetpub\wwwroot\somesite.com\someFolder\dink2\muffin.gif" 
File.Copy(copyPath, copyPath2) 

但這不起作用

Dim copyPath As String = Server.MapPath("~/someFolder/dink1/" + fileName) 
Dim copyPath2 As String = Server.MapPath("~/someFolder/dink2/" + fileName) 
File.Copy(copyPath, copyPath2) 

什麼我需要做的正確這裏打造出來的路徑?

+0

什麼是文件名? – ataravati

+1

您是否驗證過copyPath和copyPath2包含的內容?另外 - 你有錯誤信息嗎? –

+1

添加聲明兩個代碼路徑的代碼返回相同的字符串。告訴我們會發生什麼(File.Copy不'知道'字符串是如何構建的)。 –

回答