本文介紹了使用 VB.NET 將文件上傳到 FTP 站點(diǎn)的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!
問(wèn)題描述
限時(shí)送ChatGPT賬號(hào)..
我從這個(gè) link 獲得了這個(gè)工作代碼,用于將文件上傳到一個(gè) ftp 站點(diǎn):
I have this working code from this link, to upload a file to an ftp site:
' set up request...
Dim clsRequest As System.Net.FtpWebRequest = _
DirectCast(System.Net.WebRequest.Create("ftp://ftp.myserver.com/test.txt"), System.Net.FtpWebRequest)
clsRequest.Credentials = New System.Net.NetworkCredential("myusername", "mypassword")
clsRequest.Method = System.Net.WebRequestMethods.Ftp.UploadFile
' read in file...
Dim bFile() As Byte = System.IO.File.ReadAllBytes("C:Temp est.txt")
' upload file...
Dim clsStream As System.IO.Stream = _
clsRequest.GetRequestStream()
clsStream.Write(bFile, 0, bFile.Length)
clsStream.Close()
clsStream.Dispose()
不知道,如果ftp目錄下已經(jīng)存在該文件,會(huì)不會(huì)覆蓋該文件?
I wonder, if the file already exists in the ftp directory, the file will be overwritten?
推薦答案
查看MSDN 文檔映射到 FTP STOR 命令.查看 FTP STOR 命令的定義,如果用戶有權(quán)限,它將覆蓋現(xiàn)有文件.
Looking at the MSDN documentation this maps to the FTP STOR command. Looking at the definition for the FTP STOR command it will overwrite existing files, if the user has permissions.
所以在這種情況下,是的,文件將被覆蓋.
So in this case, yes the file would be overwritten.
這篇關(guān)于使用 VB.NET 將文件上傳到 FTP 站點(diǎn)的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!