Click here to Skip to main content
15,921,577 members
Home / Discussions / C#
   

C#

 
GeneralFlicker Free RichTextBox Pin
Peter Vertes16-Jun-04 4:32
Peter Vertes16-Jun-04 4:32 
GeneralRe: Flicker Free RichTextBox Pin
Stefan Troschuetz16-Jun-04 5:04
Stefan Troschuetz16-Jun-04 5:04 
GeneralRe: Flicker Free RichTextBox Pin
leppie16-Jun-04 7:06
leppie16-Jun-04 7:06 
GeneralGetting Icon Name from notifyIcon1 Pin
cbmdk16-Jun-04 3:31
cbmdk16-Jun-04 3:31 
GeneralRe: Getting Icon Name from notifyIcon1 Pin
Dave Kreskowiak16-Jun-04 4:21
mveDave Kreskowiak16-Jun-04 4:21 
GeneralRe: Getting Icon Name from notifyIcon1 Pin
Mike Dimmick16-Jun-04 4:25
Mike Dimmick16-Jun-04 4:25 
GeneralHttpWebRequest - Only Partial Page Returned Pin
bludvl9016-Jun-04 3:26
bludvl9016-Jun-04 3:26 
GeneralRe: HttpWebRequest - Only Partial Page Returned Pin
Heath Stewart16-Jun-04 4:28
protectorHeath Stewart16-Jun-04 4:28 
This could be many things, such as not buffering the output correctly (never read-in the whole page at once - that's a bad idea) or using the wrong Encoding if you are buffering the whole output page.

Lets say you do buffer the whole page:
byte[] buffer = new byte[response.ContentLength];
response.Read(buffer, 0, buffer.Length);
And then you use the wrong Encoding to read it. Lets say a Unicode (1-4 bytes per character) character set is returned but you assume ASCII:
string s = Encoding.ASCII.GetString(buffer);
Only part of the page would be read because ASCII is 1 byte per character.

Instead, use the HttpWebResponse.ContentEncoding to get the right Encoding class:
Encoding enc = Encoding.GetEncoding(response.ContentEncoding);
string s = enc.GetString(buffer);


The easiest way is to create a StreamReader over the output using the right encoding. This will take care of any problems with buffering, even if you were to use StreamReader.ReadToEnd:
Encoding enc = Encoding.GetEncoding(response.ContentEncoding);
StreamReader reader = new StreamReader(response.GetResponseStream(), enc);
string line = null;
do
{
  line = reader.ReadLine();
  Console.WriteLine(line);
} while (line != null);


 

Microsoft MVP, Visual C#
My Articles
GeneralShell execute in C# Pin
Member 445055116-Jun-04 3:24
Member 445055116-Jun-04 3:24 
GeneralRe: Shell execute in C# Pin
Colin Angus Mackay16-Jun-04 3:36
Colin Angus Mackay16-Jun-04 3:36 
GeneralRe: Shell execute in C# Pin
Member 445055116-Jun-04 5:55
Member 445055116-Jun-04 5:55 
GeneralGet type of derived class from base class Pin
joev16-Jun-04 3:06
joev16-Jun-04 3:06 
GeneralRe: Get type of derived class from base class Pin
Heath Stewart16-Jun-04 4:21
protectorHeath Stewart16-Jun-04 4:21 
GeneralRe: Get type of derived class from base class Pin
joev16-Jun-04 10:39
joev16-Jun-04 10:39 
GeneralRe: Get type of derived class from base class Pin
joev16-Jun-04 10:53
joev16-Jun-04 10:53 
GeneralRe: Get type of derived class from base class Pin
Heath Stewart16-Jun-04 10:58
protectorHeath Stewart16-Jun-04 10:58 
GeneralRe: Get type of derived class from base class Pin
joev16-Jun-04 11:09
joev16-Jun-04 11:09 
Generalline color of textBox or listBox Pin
Member 117814516-Jun-04 2:03
Member 117814516-Jun-04 2:03 
GeneralRe: line color of textBox or listBox Pin
LongRange.Shooter16-Jun-04 4:13
LongRange.Shooter16-Jun-04 4:13 
GeneralRe: line color of textBox or listBox Pin
Member 117814516-Jun-04 4:26
Member 117814516-Jun-04 4:26 
GeneralInterfaces in C# Pin
saud_a_k16-Jun-04 1:46
saud_a_k16-Jun-04 1:46 
GeneralRe: Interfaces in C# Pin
IamADotNetGuy16-Jun-04 3:39
IamADotNetGuy16-Jun-04 3:39 
GeneralRe: Interfaces in C# Pin
LongRange.Shooter16-Jun-04 4:27
LongRange.Shooter16-Jun-04 4:27 
GeneralRe: Interfaces in C# Pin
saud_a_k16-Jun-04 18:40
saud_a_k16-Jun-04 18:40 
GeneralRe: Interfaces in C# Pin
Stefan Troschuetz16-Jun-04 19:31
Stefan Troschuetz16-Jun-04 19:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.