FtpWebRequest.Method = "UploadFile"

it worked before, and maybe after beta2, it stopped working. now it says "This method is not supported"

How to get around of this? could not find anything about this on web.

Thanks,

PublicSub FtpUpload(ByVal uploadAddressAsString,ByVal fileToUploadAsString,ByVal credentialsAs NetworkCredential)

Dim requestAs FtpWebRequest =Nothing

Dim responseAs FtpWebResponse =Nothing

Dim srAs StreamReader =Nothing

Dim swAs StreamWriter =Nothing

Try

request =CType(FtpWebRequest.Create(New Uri(uploadAddress)), FtpWebRequest)

request.Method ="UploadFile"

request.Credentials = credentials

sw =New StreamWriter(request.GetRequestStream, Encoding.ASCII)

sr =New StreamReader(fileToUpload)

sw.Write(sr.ReadToEnd)

'Console.WriteLine("Uploading file " + uploadAddress)

response =CType(request.GetResponse, FtpWebResponse)

'Console.WriteLine("Status of upload: " + response.StatusDescription)

Catch exAs UriFormatException

ThrowNew ApplicationException("FTP address is not correct." & uploadAddress)

Catch exAs WebException

ThrowNew ApplicationException("FtpUpload Failed: " & ex.Message, ex)

Catch exAs Exception

Throw ex

Finally

If responseIsNotNothingThen response.Close()

If srIsNotNothingThen sr.Close()

If swIsNotNothingThen sw.Close()

EndTry

EndSub

[5120 byte] By [WeiWangfatheroftwins] at [2008-2-21]
# 1
In request.Method = "UploadFile"
change the method to STOR or use WebRequestMethods.Ftp.UploadFile
Malar at 2007-9-9 > top of Msdn Tech,.NET Development,.NET Framework Networking and Communication...
# 2
Thanks, that is it.
WeiWangfatheroftwins at 2007-9-9 > top of Msdn Tech,.NET Development,.NET Framework Networking and Communication...

.NET Development

Site Classified