[asp.net]將一個檔案複製到另外一個資料夾

  • 8205
  • 0

摘要:[asp.net]將一個資料夾的所有檔案複製到另外一個資料夾

首先當然要import

Imports System.IO

然後只要一行就可完成啦!!XD

Dim strTime As String = DateTime.Now.ToString("yyyyMMdd hhmmss")
        Dim strFileDirPath As String = Server.MapPath("~\Temp\" & strTime & "_" & Session("UID").ToString & "_" & "ZipAndDownload")
        If Not System.IO.Directory.Exists(strFileDirPath) Then
            System.IO.Directory.CreateDirectory(strFileDirPath)
        End If
        File.Copy(Server.MapPath("~\Temp\" & strTime & "_" & Session("UID").ToString & "_" & "ZipAndDownload"), Server.MapPath("~\Temp\" & strTime & "_" & Session("UID").ToString & "_" & "ZipAndDownload"))

有相關性的文章

利用程式碼將多個檔案做成一個壓縮檔(zip,PutNextEntry)