2012-04-05 39 views
1
If System.IO.Directory.Exists(HttpContext.Current.Server.MapPath("images/TravelogueGallery/" & getMaxID())) Then 
    System.IO.Directory.Delete(HttpContext.Current.Server.MapPath("images/TravelogueGallery/" & getMaxID()), True) 
End If 

我使用上面的代码片段删除一个目录,但我得到这个错误:资料夹删除不工作

'G:\Projects\Latest\LTCIndia 05-04-12 1415\images\TravelogueGallery\19' is not a valid virtual path.

有什么不好的代码?

更新:我已经用正确答案更新了这个问题。上面的代码片段工作得很好。谢谢你们的时间。

+0

删除删除行上的MapPath。看看是否有帮助。 – asawyer 2012-04-05 23:26:39

+0

http://stackoverflow.com/questions/942514/is-not-a-valid-virtual-path – 2012-04-05 23:28:31

+0

可能的重复检查你的相对路径。 – coder 2012-04-05 23:29:13

回答

0
If System.IO.Directory.Exists(HttpContext.Current.Server.MapPath("images/TravelogueGallery/" & getMaxID())) Then 
    System.IO.Directory.Delete(HttpContext.Current.Server.MapPath("images/TravelogueGallery/" & getMaxID()), True) 
End If 

这是正确的答案。 我用正确的答案更新了问题。上面的代码片段工作得很好。谢谢你们的时间。