我在temp文件夹中有五个zip文件,可以下载该文件。我的目的是下载所有文件,但现在下载第一个文件。
我尝试使用此代码下载所有文件
将我视作整数
Dim TxtLocalSysName As String = Request.UserHostName
Dim readStream As FileStream
Dim writeStream As FileStream
Try
For i = 0 To lstdownload.Items.Count - 1
Dim filePath As String = Me.Label5.Text + "\" + lstdownload.Items(i).Text
Dim targetFile As System.IO.FileInfo = New System.IO.FileInfo(filePath)
readStream = New FileStream(filePath, FileMode.Open)
Dim length As Integer = Convert.ToInt32(readStream.Length)
'This is the buffer.
Dim byteFile() As Byte = New Byte(length) {}
readStream.Read(byteFile, 0, length)
readStream.Close()
Dim localPath As String = "\\" & TxtLocalSysName & "\c$\downloads"
If Not Directory.Exists(localPath) Then
Directory.CreateDirectory(localPath)
End If
writeStream = New FileStream(localPath & "\" & targetFile.Name, FileMode.Create)
writeStream.Write(byteFile, 0, length)
writeStream.Close()
Next i
Catch ex As Exception
Console.WriteLine("The process failed: {0}", ex.ToString())
Finally
readStream.Close()
readStream.Dispose()
writeStream.Close()
writeStream.Dispose()
End Try
我将网站放在服务器端,因此所有zip文件都下载在服务器端的temp文件夹中。我需要客户端临时文件夹中的所有zip文件