Link to home
Start Free TrialLog in
Avatar of suicehockey44
suicehockey44

asked on

C# App post *.csv file to website

Hi.
 I've created a small app that logs on to a website. I am not using a WebBrowser but using HttpWebRequest and WebResponse. So now I have:

StreamReader streamReader = new StreamReader(webresponse.GetResponseStream());
string html = streamReader.ReadToEnd();


In that html, somewhere, is a text box to add a file location and a POST method.

How do I target these properties/methods using HttpWebRequest?

Thank you.

Avatar of kris_per
kris_per


Once you find out the url to upload from the html, then for single file uploads using WebClient is simpler than using HttpWebRequest/POST

WebClient client = new WebClient();

byte[] responseBinary = client.UploadFile(url, fileName);

string response = Encoding.UTF8.GetString(responseBinary);

You can check out this link => http://aspnetupload.com/Upload-File-POST-HttpWebRequest-WebClient-RFC-1867.aspx
ASKER CERTIFIED SOLUTION
Avatar of kris_per
kris_per

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial