FTP Upload - needs help badly

T

tpthai

Hi,
Please help me with my vb dotnet code. I'm trying to upload a file to
an ftp website. The program seems hung on this line of code
"wrqToVendor.GetResponse". I'm not getting anything back.

I tried the webclient upload but it does not work for .NET framework
1.1. If you have any other suggestions, please let me know.

Appreciated your help in advance.

Teresa


Dim wrqToVendor As WebRequest
Dim wrsFromVendor As WebResponse
Dim thisStream As System.IO.Stream
Dim srReadLine As System.IO.StreamReader

wrqToVendor = WebRequest.Create("http://ftp.mywebsite.com" + "?" +
"c:\temp\test.txt")
wrqToVendor.Method = "PUT"
Dim myCred As New Net.NetworkCredential("myid", "mypassw")
wrqToVendor.Credentials = myCred
wrsFromVendor = wrqToVendor.GetResponse()
thisStream = wrsFromVendor.GetResponseStream
srReadLine = New System.IO.StreamReader(thisStream,
System.Text.Encoding.ASCII)

While (srReadLine.Peek() > -1)
value += srReadLine.ReadLine()
valueLineCount += 1
End While

wrsFromVendor.Close()
thisStream.Close()
srReadLine.Close()
 
K

Ken Tucker [MVP]

Hi,

Here is a link to an ftp class for vb.net. It includes an
example of uploading a file.

http://support.microsoft.com/default.aspx?scid=kb;en-us;832679

Ken
------------------
Hi,
Please help me with my vb dotnet code. I'm trying to upload a file to
an ftp website. The program seems hung on this line of code
"wrqToVendor.GetResponse". I'm not getting anything back.

I tried the webclient upload but it does not work for .NET framework
1.1. If you have any other suggestions, please let me know.

Appreciated your help in advance.

Teresa


Dim wrqToVendor As WebRequest
Dim wrsFromVendor As WebResponse
Dim thisStream As System.IO.Stream
Dim srReadLine As System.IO.StreamReader

wrqToVendor = WebRequest.Create("http://ftp.mywebsite.com" + "?" +
"c:\temp\test.txt")
wrqToVendor.Method = "PUT"
Dim myCred As New Net.NetworkCredential("myid", "mypassw")
wrqToVendor.Credentials = myCred
wrsFromVendor = wrqToVendor.GetResponse()
thisStream = wrsFromVendor.GetResponseStream
srReadLine = New System.IO.StreamReader(thisStream,
System.Text.Encoding.ASCII)

While (srReadLine.Peek() > -1)
value += srReadLine.ReadLine()
valueLineCount += 1
End While

wrsFromVendor.Close()
thisStream.Close()
srReadLine.Close()
 
A

AlexL [Xceed]

If that doesn't work out for you (stability, consistent results,
generating events you need for status, doesn't work with your
particular FTP server, etc.) you can take a look at our
latest .NET FTP component:

http://www.xceedsoft.com/products/ftpnet

Take care,

Thank you very much Ken. I'll check it out.

Teresa

--
Alex Leblanc
Xceed Software Inc.
http://www.xceedsoft.com

Check out our advanced .NET grid and SmartUI controls

Email: (e-mail address removed) (remove the first 'x')
 
Top