|
-
Aug 8th, 2011, 08:09 PM
#1
Thread Starter
Member
WebClient OpenWriteAsync Not Updating File
Hello, everyone! I'm using the WebClient class' OpenWriteAsync function, and I'm having a little trouble with it. I want it to write some information to a .txt file I have uploaded on my FTP. I made it display a message after it has completed doing so, and the message does indeed pop up. However, I've checked my .txt file numerous times, and it hasn't actually been edited. I'm wondering if someone could please help me out with this. Here's some of my code:
Code:
Dim otherclient As New WebClient()
AddHandler otherclient.OpenWriteCompleted, AddressOf WriteCompleted
otherclient.OpenWriteAsync(New Uri(URL))
Private Sub WriteCompleted(ByVal sender As System.Object, ByVal e As OpenWriteCompletedEventArgs)
Try
If e.Error Is Nothing And e.Cancelled = False Then
Dim FileStream As Stream = e.Result
Dim Bytes() As Byte = System.Text.Encoding.UTF8.GetBytes(txtTest.Text & vbNewLine)
FileStream.Write(Bytes, 0, Bytes.Length)
FileStream.Flush()
FileStream.Close()
MsgBox("Complete!")
Else
MsgBox(e.Error)
Exit Sub
End If
Catch ex As Exception
MsgBox(ex.Message)
Exit Sub
End Try
End Sub
Am I doing anything wrong or missing something? Thanks in advance!
-
Aug 9th, 2011, 04:14 PM
#2
Thread Starter
Member
Re: WebClient OpenWriteAsync Not Updating File
I'm sorry for double-posting, but I really need help with this. I've been looking online for help (with no luck), and I've tried numerous times to get this to work, but I keep experiencing the same problem: the program goes through with the entire process and says that it completed successfully, but if I check my FTP, nothing has happened.
Thanks again in advance for any help.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|