27-03-13, 01:32 PM
السلام عليكم ،،
جرب هذا الكود لقيته باحد المواقع المشكله اني لا املك أستضافه للتجربه في الوقت الحالي
جرب هذا الكود لقيته باحد المواقع المشكله اني لا املك أستضافه للتجربه في الوقت الحالي
كود :
Imports System.IO
Imports System.Net
Imports System.Text
Dim localFile As String = "C:\Yserver.txt"
Dim remoteFile As String = "ftp://ftpSERVER/test12345.txt"
Dim username As String = "user"
Dim password As String = "pwd"
Dim sourceStream As New StreamReader(localFile)
Dim fileContents As Byte() = Encoding.UTF8.GetBytes(sourceStream.ReadToEnd())
sourceStream.Close()
'Get the object used to communicate with the server.
Dim Request As System.Net.FtpWebRequest = FtpWebRequest.Create(remoteFile)
' Setting Properties
Request.Credentials = New NetworkCredential(username, password)
Request.Method = System.Net.WebRequestMethods.Ftp.UploadFile
Request.Proxy = Nothing
Request.KeepAlive = False
' Uploading file
Request.GetRequestStream.Write(fileContents, 0, fileContents.Length)
MsgBox("File Uploaded Successfully !!!")