2013-01-05 25 views
1
Partial Class admin_upload 
    Inherits System.Web.UI.Page 

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 
     Dim UpPath As String 
     Dim UpName As String 
     UpPath = "/images" 
     UpName = Dir(UpPath, vbDirectory) 
     If (UpName = "") Then 
      MkDir("/images") 
     End If 
    End Sub 

    Protected Sub uplodto_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles uplodto.Click 
     FileName.InnerHtml = FileFiled.PostedFile.FileName 
     FileContent.InnerHtml = FileFiled.PostedFile.ContentType 
     FileSize.InnerHtml = FileFiled.PostedFile.ContentLength 
     UploadDetails.Visible = True 
     Dim myfilename As String 
     myfilename = FileFiled.PostedFile.FileName 
     Dim c As String = System.IO.Path.GetFileName(myfilename) 
     Try 
      FileFiled.PostedFile.SaveAs("images\" + c) 
      Span1.InnerHtml = "File uploaded successfuly" 
     Catch ex As Exception 
      Span1.InnerHtml = "faild" 
      UploadDetails.Visible = False 
     End Try 
    End Sub 
End Class 

我想使文件的方向上的Web站點文件夾&服務器如何在網站上fileuploader使目錄文件夾

+0

方向???你的意思是目錄嗎?如果你指的是目錄,那麼我在下面回答。 – Srinivas

回答

0

如果不System.IO.Directory.Exists(使用Server.Mappath ( 「〜/圖像/」))然後 System.IO.Directory.CreateDirectory(使用Server.Mappath( 「〜/圖像/」)) 結束如果

相關問題