RcBuilder@walla.com
call centre: 054-5614020

WebClient download string

Posted by: RcBuilder  /   Category: FileStream / HttpRequest / SOURCE CODE / Stream / WebClient / WebRequest   /   No Comments
25
Nov
2014

WebClient download string get Http content using WebClient option 1 var json = new WebClient().DownloadString(url); option 2 string url = "......" var request = HttpWebRequest.Create(url); var response = request.GetResponse(); var reader = new StreamReader(response.GetResponseStream()); string jsonText = reader.ReadToEnd(); remark: don't forget to use the 'using'.

Read more

Binary Formatter

Posted by: RcBuilder  /   Category: bin / BinaryFormatter / Files / FileStream / Serialize / SOURCE CODE / Stream   /   No Comments
05
Oct
2014

Binary Formatter class Binary_Formatter { public void BaseObject(){ string Path = string.Concat(AppDomain.CurrentDomain.BaseDirectory, "test.bin"); string Name = "Roby Cohen"; Console.WriteLine("SERIALIZE " + Name); BinaryFormatter formatter = new BinaryFormatter(); using (FileStream fsWrite = new FileStream(Path, FileMode.Create)) { formatter.Serialize(fsWrite, Name); } Console.WriteLine("DESERIALIZE "); using (FileStream fsRead = new FileStream(Path, System.IO.FileMode.Open)) { string WhatsMyName = (string)formatter.Deserialize(fsRead); Console.WriteLine(WhatsMyName); } } public void CustomObject() { string Path = string.Concat(AppDomain.CurrentDomain.BaseDirectory, "test2.bin"); User user = new User(33, "Shirly Massa", "somewhere over the rainbow"); Console.WriteLine("SERIALIZE USER"); BinaryFormatter formatter.

Read more

Stream – Download File

Posted by: RcBuilder  /   Category: Files / HttpRequest / SOURCE CODE / Stream   /   No Comments
30
Sep
2014

Stream - Download File public static void CreateStreamDownload(string fileName) { System.IO.Stream stream = null; //This controls how many bytes to read at a time and send to the client int bytesToRead = 10000; // Buffer to read bytes in chunk size specified above byte; // The number of bytes read try { //Create a WebRequest to get the file HttpWebRequest fileReq = (HttpWebRequest)HttpWebRequest.Create(string.Concat(CSCode.BLL.Config.Keys.HostSyncAddress, "Uploaded/temp/", fileName)); //Create a response.

Read more

Captcha – basics

Posted by: RcBuilder  /   Category: Bitmap / Captcha / GDI+ / Graphics / image / ImageFormat / SOURCE CODE / Stream   /   No Comments
30
Jul
2014

Captcha - basics the logic behind the captcha is simple - you have to create an handler generates some value(such as numbers or letters) using GDI+ tech it creates an image containing the above value and write it directly to the response stream, in addition - it update the current session with the created value for later.

Read more

WebRequest with Proxy

Posted by: RcBuilder  /   Category: Network / Proxy / SOURCE CODE / Stream / WebRequest   /   No Comments
07
Jul
2014

WebRequest with Proxy HttpWebRequest WebReq = (HttpWebRequest)WebRequest.Create(url); .... .... WebReq.Proxy = new WebProxy("119.233.255.24:843", true); .... .... HttpWebResponse WebResp = (HttpWebResponse)WebReq.GetResponse(); .... .... using (Stream response = WebResp.GetResponseStream()) using (StreamReader content = new StreamReader(response)) return.

Read more

Regex noc.co.il my ip

Posted by: RcBuilder  /   Category: Regex / Regular Expressions / SOURCE CODE / Stream / WebRequest   /   No Comments
07
Jul
2014

HttpStatusCode STATUS; // need to implement - method that executes http web request to the supplied url - return the site html source string res = Helper.GET("http://noc.co.il/", string.Empty, out STATUS); var ip = Regex.Match(res, @"<b>Your \s+ IP \s+ address \s+ is: \s+ (?<address>\d+\.\d+\.\d+\.\d+)</b>", RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace).Groups.Value.Trim(); Console.WriteLine("STATUS = " + STATUS + " IP = " +.

Read more

Network Stream Using Socket Async

Posted by: RcBuilder  /   Category: Network / Socket / SOURCE CODE / Stream / TCP / Value Types   /   No Comments
17
Jun
2014

Network Stream Using Socket Async SERVER  public class Server { private Socket listener = null; private const int PORT = 6655; private bool isListening = false; private Encoding encoder = Encoding.UTF8; public void Start() { if (isListening) return; isListening = true; listener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); listener.Bind(new IPEndPoint(IPAddress.Any, PORT)); listener.Listen(0); listener.BeginAccept(onSocketAccepted, null); } private void onSocketAccepted(IAsyncResult ar) // LOOP { using (var client = listener.EndAccept(ar)) HandleClient(client); listener.BeginAccept(onSocketAccepted, null); } private void HandleClient(Socket client) { var buffer_read = new byte; int.

Read more

Network Stream Using Socket

Posted by: RcBuilder  /   Category: Network / Socket / SOURCE CODE / Stream / TCP / Value Types   /   No Comments
17
Jun
2014

Network Stream Using Socket SERVER public class Server { private Socket listener = null; private const int PORT = 6655; private Encoding encoder = Encoding.UTF8; public void Start() { using (listener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)) { listener.Bind(new IPEndPoint(IPAddress.Any, PORT)); listener.Listen(100); // connection pool while (true) { using (var client = listener.Accept()) { var buffer_read = new byte; int bytes_read = client.Receive(buffer_read); string request = string.Empty; if (bytes_read > 0) { using (var ms = new MemoryStream()) { ms.Write(buffer_read,.

Read more

Network Stream Using TCP

Posted by: RcBuilder  /   Category: Network / Socket / SOURCE CODE / Stream / TCP / Value Types   /   No Comments
17
Jun
2014

Network Stream Using TCP SERVER public class Server { private TcpListener listener = null; private const int PORT = 6655; private Encoding encoder = Encoding.UTF8; public void Start() { listener = new TcpListener(IPAddress.Any, PORT); listener.Start(); while(true){ using (var client = listener.AcceptTcpClient()) { string request = string.Empty; using (var stream = client.GetStream()) { // read request from client using (var ms = new MemoryStream()) { byte; int bytes_read = 0; bytes_read = stream.Read(buffer_read, 0, buffer_read.Length); if (bytes_read.

Read more
12
  • פיתוח מערכות
  • פתרונות טכנולוגים
  • קידום אתרים
  • בניית אתרים