99偷拍视频精品区一区二,口述久久久久久久久久久久,国产精品夫妇激情啪发布,成人永久免费网站在线观看,国产精品高清免费在线,青青草在线观看视频观看,久久久久久国产一区,天天婷婷久久18禁,日韩动漫av在线播放直播

vb.net下用ftp vbnet web

VB.net連接FTP操作

MSDN上的,看看對你有沒有幫助。GOOD LUCK!

公司主營業務:網站制作、成都網站設計、移動網站開發等業務。幫助企業客戶真正實現互聯網宣傳,提高企業的競爭能力。創新互聯公司是一支青春激揚、勤奮敬業、活力青春激揚、勤奮敬業、活力澎湃、和諧高效的團隊。公司秉承以“開放、自由、嚴謹、自律”為核心的企業文化,感謝他們對我們的高要求,感謝他們從不同領域給我們帶來的挑戰,讓我們激情的團隊有機會用頭腦與智慧不斷的給客戶帶來驚喜。創新互聯公司推出山亭免費做網站回饋大家。

Imports System.Net

Imports System.IO

Module FtpSample

Sub Main(ByVal args() As String)

If args.Length = 0 OrElse args(0).Equals("/?") Then

DisplayUsage()

ElseIf args.Length = 1 Then

Download(args(0))

ElseIf args.Length = 2 Then

If args(0).Equals("/list") Then

List(args(1))

Else

Upload(args(0), args(1))

End If

Else

Console.WriteLine("Unrecognized argument.")

End If

End Sub

Private Sub DisplayUsage()

Console.WriteLine("USAGE:")

Console.WriteLine(" FtpSample [/? | FTP download URL | local file")

Console.WriteLine(" FTP upload URL | /list FTP list URL]")

Console.WriteLine()

Console.WriteLine("where")

Console.WriteLine(" FTP download URL URL of a file to download from an FTP server.")

Console.WriteLine(" FTP upload URL Location on a FTP server to upload a file to.")

Console.WriteLine(" FTP list URL Location on a FTP server to list the contents of.")

Console.WriteLine(" local file A local file to upload to an FTP server.")

Console.WriteLine()

Console.WriteLine(" Options:")

Console.WriteLine(" /? Display this help message.")

Console.WriteLine(" /list Specifies the list command.")

Console.WriteLine()

Console.WriteLine("EXAMPLES:")

Console.WriteLine(" Download a file FtpSample ")

Console.WriteLine(" Upload a file FtpSample upload.txt ")

End Sub

Private Sub Download(ByVal downloadUrl As String)

Dim responseStream As Stream = Nothing

Dim fileStream As FileStream = Nothing

Dim reader As StreamReader = Nothing

Try

Dim downloadRequest As FtpWebRequest = _

WebRequest.Create(downloadUrl)

Dim downloadResponse As FtpWebResponse = _

downloadRequest.GetResponse()

responseStream = downloadResponse.GetResponseStream()

Dim fileName As String = _

Path.GetFileName(downloadRequest.RequestUri.AbsolutePath)

If fileName.Length = 0 Then

reader = New StreamReader(responseStream)

Console.WriteLine(reader.ReadToEnd())

Else

fileStream = File.Create(fileName)

Dim buffer(1024) As Byte

Dim bytesRead As Integer

While True

bytesRead = responseStream.Read(buffer, 0, buffer.Length)

If bytesRead = 0 Then

Exit While

End If

fileStream.Write(buffer, 0, bytesRead)

End While

End If

Console.WriteLine("Download complete.")

Catch ex As UriFormatException

Console.WriteLine(ex.Message)

Catch ex As WebException

Console.WriteLine(ex.Message)

Catch ex As IOException

Console.WriteLine(ex.Message)

Finally

If reader IsNot Nothing Then

reader.Close()

ElseIf responseStream IsNot Nothing Then

responseStream.Close()

End If

If fileStream IsNot Nothing Then

fileStream.Close()

End If

End Try

End Sub

Private Sub Upload(ByVal fileName As String, ByVal uploadUrl As String)

Dim requestStream As Stream = Nothing

Dim fileStream As FileStream = Nothing

Dim uploadResponse As FtpWebResponse = Nothing

Try

Dim uploadRequest As FtpWebRequest = WebRequest.Create(uploadUrl)

uploadRequest.Method = WebRequestMethods.

' UploadFile is not supported through an Http proxy

' so we disable the proxy for this request.

uploadRequest.Proxy = Nothing

requestStream = uploadRequest.GetRequestStream()

fileStream = File.Open(fileName, FileMode.Open)

Dim buffer(1024) As Byte

Dim bytesRead As Integer

While True

bytesRead = fileStream.Read(buffer, 0, buffer.Length)

If bytesRead = 0 Then

Exit While

End If

requestStream.Write(buffer, 0, bytesRead)

End While

' The request stream must be closed before getting the response.

requestStream.Close()

uploadResponse = uploadRequest.GetResponse()

Console.WriteLine("Upload complete.")

Catch ex As UriFormatException

Console.WriteLine(ex.Message)

Catch ex As IOException

Console.WriteLine(ex.Message)

Catch ex As WebException

Console.WriteLine(ex.Message)

Finally

If uploadResponse IsNot Nothing Then

uploadResponse.Close()

End If

If fileStream IsNot Nothing Then

fileStream.Close()

End If

If requestStream IsNot Nothing Then

requestStream.Close()

End If

End Try

End Sub

Private Sub List(ByVal listUrl As String)

Dim reader As StreamReader = Nothing

Try

Dim listRequest As FtpWebRequest = WebRequest.Create(listUrl)

listRequest.Method = WebRequestMethods.

Dim listResponse As FtpWebResponse = listRequest.GetResponse()

reader = New StreamReader(listResponse.GetResponseStream())

Console.WriteLine(reader.ReadToEnd())

Console.WriteLine("List complete.")

Catch ex As UriFormatException

Console.WriteLine(ex.Message)

Catch ex As WebException

Console.WriteLine(ex.Message)

Finally

If reader IsNot Nothing Then

reader.Close()

End If

End Try

End Sub

End Module

可以通過設置 Credentials 屬性來指定用于連接服務器的憑據,也可以將它們包含在傳遞給 Create 方法的 URI 的 UserInfo 部分中。

從 FTP 服務器下載文件時,如果命令成功,所請求的文件的內容即在響應對象的流中。通過調用 GetResponseStream 方法,可以訪問此流。

如果使用 FtpWebRequest 對象向服務器上載文件,則必須將文件內容寫入請求流,請求流是通過調用 GetRequestStream 方法或其異步對應方法(BeginGetRequestStream 和 EndGetRequestStream 方法)獲取的。必須寫入流并在發送請求之前關閉該流。

請求是通過調用 GetResponse 方法或其異步對應方法(BeginGetResponse 和 EndGetResponse 方法)發送到服務器的。請求的操作完成時,會返回一個 FtpWebResponse 對象。FtpWebResponse 對象提供操作的狀態以及從服務器下載的所有數據。

VBNET從FTP下載文件,需要先判斷文件是否存在嗎

需要。

在實際使用FTP文件服務器的過程中,經常需要遠程下載解析文件。為提高效率,需要判斷文件存在與否,有選擇的進行解析。

FTP協議是一個用于在計算機網絡上客戶端和服務器之間進行文件傳輸的應用層協議,包括FTP服務器和FTP客戶端兩個組成部分。FTP能操作任何類型的文件而不需要進一步處理,但有著極高的延時,從開始請求到第一次接收需求數據之間的時間較長,并不時地執行一些冗長的登錄進程。

vb.net FTP問題?

If My.Computer.Network.IsAvailable Then

'如果可用

Else

'不可用

End If

Public Sub DownloadFile ( _

address As Uri, _

destinationFileName As String, _

userName As String, _

password As String, _

showUI As Boolean, _

connectionTimeout As Integer, _

overwrite As Boolean, _

onUserCancel As UICancelOption _

)

參數

address

String 或 Uri。要下載的文件的路徑,包括文件名和主機地址。必選。

destinationFileName

String。下載文件的文件名和路徑。必選。

userName

String。要進行身份驗證的用戶名。默認值為空字符串 ""。

password

String。要進行身份驗證的密碼。默認值為空字符串 ""。

showUI

Boolean。指定是否顯示操作進度。默認為 False。

connectionTimeout

Int32。以毫秒為單位的超時間隔。默認值為 100 秒。

overwrite

Boolean。指定是否改寫現有文件。默認為 False。

onUserCancel

UICancelOption。指定當用戶在對話框(此對話框在 ShowUI 設置為 True 時顯示)上單擊“取消”或“否”時的行為。默認為 ThrowException。

VB.NET 怎么將FTP文件移動到FTP下另一個目錄中去

給你個方法原型:

File.Copy("~\*.*","~\",Boolean)第一個參數是String,指定原文件的Path;

第二個參數是String,指定拷貝目標Path;

第三個參數是Boolean,表示覆蓋同名文件。

自己修改一下即可。

當前名稱:vb.net下用ftp vbnet web
網頁路徑:http://www.yijiale78.com/article44/hhigee.html

成都網站建設公司_創新互聯,為您提供品牌網站建設、做網站、外貿網站建設、網站排名、小程序開發自適應網站

廣告

聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯

綿陽服務器托管