Appending to text file on server

1kat

Member
Joined
Dec 10, 2011
Messages
5
Programming Experience
3-5
Is it possible to append text to a text file located on a webserver from a winform? If so, can you please point me in the right direction. I've searched this forum but can only find documentation on appending a local text file.
 

jmcilhinney

VB.NET Forum Moderator
Staff member
Joined
Aug 17, 2004
Messages
14,349
Location
Sydney, Australia
Programming Experience
10+
No it's not. You would have to download the file, make whatever edits are required and then upload the new file contents in their entirety. As such, the information you have already found is quite relevant. You just have to add a download before and an upload after.
 

1kat

Member
Joined
Dec 10, 2011
Messages
5
Programming Experience
3-5
Thanks jmcilhinney,

I would have wasted more time looking for a way to do that. I did however find a workaround that accomplished my goal since downloading the file to make the changes and then uploading it wouldn't have worked in my situation.

You have to know PHP for the workaround and it involves passing variables through a url.

I added a webbrowser control to my form and turned it's visibility to false. Then I used the following code to pass the variables to a PHP page that I wanted to append to the text file.

webbrowser.navigate("http://www.mysite.com/page.php?variable1=textbox.text&variable2=textbox2.text&variable3=textbox3.text") 'the bold part passes the variables.

Then on my page.php page I retrieved the variables and appended them to the text file.

The reason I made a webbrowser control on the form was so that my line of code above did not actually open up the default webbrowser on the computer.

Note: passing variables through a url is not secure so I wouldn't do this with sensitive data.
 
Top Bottom