从我的服务器下载文件 [英] Download a file from my server
本文介绍了从我的服务器下载文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试从我的服务器下载文件。
它位于我在线网站的根目录中:( root)\ftp1 \ GraphPlanets.zip
我服务器上的ftpuser和密码打开到一个文件夹,它设置为:\ ftp1 \
这是我的下载代码:
I am trying to download a file from my server.
It resides in the root directory of my online site: (root)\ftp1\GraphPlanets.zip
The ftpuser and password on my server open to a folder and it is set to: \ftp1\
Here is my code to download:
' Create the request.
Dim request As FtpWebRequest = FtpWebRequest.Create("ftp://ftp.philosophaie.com/GraphingPlanets.zip")
request.Credentials = New NetworkCredential("ftpuser", "pass")
request.KeepAlive = False
request.UseBinary = True
request.UsePassive = True
request.Method = WebRequestMethods.Ftp.DownloadFile
' Save the file to the file system.
Using response As System.Net.FtpWebResponse = CType(request.GetResponse, System.Net.FtpWebResponse)
Using responseStream As IO.Stream = response.GetResponseStream
Using fs As New IO.FileStream(Server.MapPath("\ftp1\GraphingPlanets.zip"), IO.FileMode.Create)
Dim buffer(2047) As Byte
Dim read As Integer = 0
Do
read = responseStream.Read(buffer, 0, buffer.Length)
fs.Write(buffer, 0, read)
Loop Until read = 0
responseStream.Close()
fs.Flush()
fs.Close()
End Using
responseStream.Close()
End Using
response.Close()
End Using
推荐答案
您是否正在尝试在VB中创建一个客户端应用程序,它将从您的FTP服务器下载文件?
如果是这样,您可以查看以下文章:
FTP客户端库for .NET 2.0 [ ^ ]
当然适用于.NET 2.0,但不应该使用Visual Studio进行转换转换向导。
http://msdn.microsoft.com/en-us/library/dd483478(v = VS.100 ).aspx [ ^ ]
希望这会有所帮助。
Are you trying to make a client side app in VB that will download files from your FTP server?
If so, you might check out the following article:
An FTP client library for .NET 2.0[^]
Sure that is for .NET 2.0, but it shouldn't be to hard to convert using the Visual Studio Conversion Wizard.
http://msdn.microsoft.com/en-us/library/dd483478(v=vs.100).aspx[^]
Hope this helps.
这篇关于从我的服务器下载文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文