Hi all,
I picked this code up off the web, with lots of responders saying "This works great!"
However, all instances of clsRequest and clsStream other than the Dim statements produce a "Delclaration Expected" error.
Any ideas?
I picked this code up off the web, with lots of responders saying "This works great!"
Imports System
Imports System.Net
Imports System.Data.SqlClient
Imports System.Data
Imports System.IO
Public Class Form1
Dim clsrequest As System.Net.FtpWebRequest = DirectCast(System.Net.WebRequest.Create("ftp://74.151.58.17/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\test.txt")
' upload file...
Dim clsStream As System.IO.Stream = clsRequest.GetRequestStream()
clsStream.Write(bFile, 0, bFile.Length)
clsStream.Close()
clsStream.Dispose()
End Class
Imports System.Net
Imports System.Data.SqlClient
Imports System.Data
Imports System.IO
Public Class Form1
Dim clsrequest As System.Net.FtpWebRequest = DirectCast(System.Net.WebRequest.Create("ftp://74.151.58.17/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\test.txt")
' upload file...
Dim clsStream As System.IO.Stream = clsRequest.GetRequestStream()
clsStream.Write(bFile, 0, bFile.Length)
clsStream.Close()
clsStream.Dispose()
End Class
However, all instances of clsRequest and clsStream other than the Dim statements produce a "Delclaration Expected" error.
Any ideas?