0

Possible Duplicate:
.NET equivalent of Java’s BufferedReader

This is my code in Java. I want to convert it to c#. Can you please help me?

BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(connect.getOutputStream()));
writer.write("username=0920307&password=85181395&submit=Login");
writer.close();
BufferedReader reader = new BufferedReader(new InputStreamReader(connect.getInputStream()));
Community
  • 1
  • 1
pmark019
  • 1,199
  • 5
  • 15
  • 24

1 Answers1

4

The C# equivalent to Java's Buffered Writer is StreamWriter.

Good luck with your project.

XTC
  • 64
  • 2
  • how about this part? what is the equivalent of this in c#? (new OutputStreamWriter(connect.getOutputStream())); connect is a HttpWebRequest. – pmark019 Oct 14 '12 at 08:49
  • Hi Le, Just to understand what you are trying to accomplish here. If I understand your code fragment correctly then you are trying to send a username/password combination to to an external site or networked service, the catching the response(I presume it is over HTTP) correct me if I am wrong. If I am right maybe this can help: [link](http://stackoverflow.com/questions/4015324/http-request-with-post) – XTC Oct 14 '12 at 09:35
  • You are right. I tried the suggestions in the link but some of the codes doesn't work such as ASCIIEncoding and ContentLength. I'm using visual studio 2010 and I'm making an application for windows phone 7. – pmark019 Oct 14 '12 at 10:35
  • Hi Le, sorry I was not back sooner. I had some unfinished work (:still have :-)) that i need to do. For all of us coming from outside the US ASCIIEncoding almost never works, guessing that you work against a Vietnamese site, you probably need to use UTF8 encoding or maybe UTF16 I have found this [link](http://vietunicode.sourceforge.net/main.html. I think ContentLength should work, som my guess is you have some other issue with your code. Br. – XTC Oct 14 '12 at 15:26