By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,563 Members | 1,058 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,563 IT Pros & Developers. It's quick & easy.

VB 2005b2 FtpWebRequest with method UploadFile returns readonly stream

P: n/a
Hello group,
using the new ftp-methods from dotnet 2.0(using Beta 2), i try to upload a
file to a ftp server. According to the documentation i write the data on the
stream returned from GetResponseStream , but this stream is readonly!
I checked param and configuration of the used ftp-sites.

Hers some code:
Public Shared Function PutFile(ByVal path As String, ByVal host As String,
ByVal ftpPath As String, ByRef overwrite As Overwrite, ByVal dr As
FtpList.FSListRow, ByVal cred As NetworkCredential) As Boolean
Dim ret As Boolean = True
Dim read As Integer = 0
Dim buffer(Blocksize) As Byte
Dim fwr As FtpWebRequest
FtpDriver.PathNormalize(ftpPath)
fwr = FtpWebRequest.Create("ftp://" & host & ftpPath & dr.Name)
fwr.Credentials = cred
fwr.Method = WebRequestMethods.Ftp.UploadFile
Dim fdr As FtpWebResponse = Nothing
Dim frs As Stream = Nothing
Dim frso As Stream = Nothing
Dim sr As FileStream = Nothing
Try

fdr = fwr.GetResponse()
frs = fdr.GetResponseStream()
sr = New FileStream(path & "\" & dr.Name, FileMode.Open)
Dim r As Integer = 0
Do
r = sr.Read(buffer, 0, Blocksize)
frs.Write(buffer, 0, r)
Loop While r > 0

Anyone a idea, or just wait for the final dotnet 2.0!?

Regards
Winfried Wille

Nov 21 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.