<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>microsoft.public.dotnet.languages.csharp Latest Posts</title><link>http://msdn.microsoft.com/newsgroups/default.aspx?dg=microsoft.public.dotnet.languages.csharp</link><description>This feed provides the latest posts to the C# newsgroup on news.microsoft.com</description><item><title>Re: A very small complete program that doesn't work as expected</title><guid isPermaLink="false" /><description>Tony Johansson wrote:&lt;br&gt;&gt; Hello!&lt;br&gt;&gt; &lt;br&gt;&gt; I have a complete program listed below that use the northwind database table &lt;br&gt;&gt; Customers.&lt;br&gt;&gt; I have one control in the form and that is a DataGridView called &lt;br&gt;&gt; dataGridViewCustomer.&lt;br&gt;&gt; I use a SqlDataAdapter that pass the sql statement Select * from customers &lt;br&gt;&gt; in the c-tor.&lt;br&gt;&gt; When I run in the debugger I can see that the DataSet thisDataSet contains &lt;br&gt;&gt; all the rows that should be displayed&lt;br&gt;&gt; in the DataGridView but nothing is being displayed.&lt;br&gt;&gt; &lt;br&gt;&gt; As you can see I set the DataSource for the DataGridView to the DataSet &lt;br&gt;&gt; thisDataSet.&lt;br&gt;&gt; I event to a refresh() on the DataGridView but nothing helps.&lt;br&gt;&gt; &lt;br&gt;&gt; So does anyone know why my DataGridView doesn't display the contents of the &lt;br&gt;&gt; DataSet ?&lt;br&gt;&gt; &lt;br&gt;&lt;br&gt;&gt;    public partial class Form1 : Form&lt;br&gt;&gt;    {&lt;br&gt;&gt;       public Form1()&lt;br&gt;&gt;       {&lt;br&gt;&gt;          InitializeComponent();&lt;br&gt;&gt; &lt;br&gt;&gt;          SqlConnection thisConnection = new SqlConnection();&lt;br&gt;&gt;          thisConnection.ConnectionString = "Integrated Security=true;" +&lt;br&gt;&gt;                                            "Initial Catalog=Northwind;" +&lt;br&gt;&gt;                                            "Data Source=hempc\\SQLExpress";&lt;br&gt;&gt;          DataSet thisDataSet = new DataSet();&lt;br&gt;&gt;          SqlDataAdapter custAdapter = new SqlDataAdapter&lt;br&gt;&gt;             ("Select * from customers", thisConnection);&lt;br&gt;&gt;          custAdapter.Fill(thisDataSet, "Customers");&lt;br&gt;&gt;          this.dataGridViewCustomer.DataSource = thisDataSet;&lt;br&gt;&gt;          this.dataGridViewCustomer.Refresh();&lt;br&gt;&gt;       }&lt;br&gt;&gt;    }&lt;br&gt;&gt; &lt;br&gt;&lt;br&gt;&gt; //Tony &lt;br&gt;&gt; &lt;br&gt;&gt; &lt;br&gt;&lt;br&gt;I changed your code to the following after noticing the returned table &lt;br&gt;name was not "Customers", but was "Table" in the dataset.&lt;br&gt;&lt;br&gt;DataSet thisDataSet = new DataSet();&lt;br&gt;SqlDataAdapter custAdapter =&lt;br&gt;   new SqlDataAdapter("Select * from customers", thisConnection);&lt;br&gt;custAdapter.Fill(thisDataSet);&lt;br&gt;this.dataGridViewCustomer.DataSource = thisDataSet.Tables[0];&lt;br&gt;&lt;br&gt;&lt;br&gt;--------------------&lt;br&gt;Mike</description><pubDate>Sat, 04 Jul 2009 08:26:10 -0400</pubDate><category>C# newsgroup post</category><dc:creator>Family Tree Mike &lt;FamilyTreeMike@ThisOldHouse.com&gt;</dc:creator></item><item><title>A very small complete program that doesn't work as expected</title><guid isPermaLink="false" /><description>Hello!&lt;br&gt;&lt;br&gt;I have a complete program listed below that use the northwind database table &lt;br&gt;Customers.&lt;br&gt;I have one control in the form and that is a DataGridView called &lt;br&gt;dataGridViewCustomer.&lt;br&gt;I use a SqlDataAdapter that pass the sql statement Select * from customers &lt;br&gt;in the c-tor.&lt;br&gt;When I run in the debugger I can see that the DataSet thisDataSet contains &lt;br&gt;all the rows that should be displayed&lt;br&gt;in the DataGridView but nothing is being displayed.&lt;br&gt;&lt;br&gt;As you can see I set the DataSource for the DataGridView to the DataSet &lt;br&gt;thisDataSet.&lt;br&gt;I event to a refresh() on the DataGridView but nothing helps.&lt;br&gt;&lt;br&gt;So does anyone know why my DataGridView doesn't display the contents of the &lt;br&gt;DataSet ?&lt;br&gt;&lt;br&gt;//Here is the program&lt;br&gt;using System;&lt;br&gt;using System.ComponentModel;&lt;br&gt;using System.Data;&lt;br&gt;using System.Windows.Forms;&lt;br&gt;using System.Data.SqlClient;&lt;br&gt;   static class Program&lt;br&gt;   {&lt;br&gt;      [STAThread]&lt;br&gt;      static void Main()&lt;br&gt;      {&lt;br&gt;         Application.EnableVisualStyles();&lt;br&gt;         Application.SetCompatibleTextRenderingDefault(false);&lt;br&gt;         Application.Run(new Form1());&lt;br&gt;      }&lt;br&gt;   }&lt;br&gt;&lt;br&gt;   public partial class Form1 : Form&lt;br&gt;   {&lt;br&gt;      public Form1()&lt;br&gt;      {&lt;br&gt;         InitializeComponent();&lt;br&gt;&lt;br&gt;         SqlConnection thisConnection = new SqlConnection();&lt;br&gt;         thisConnection.ConnectionString = "Integrated Security=true;" +&lt;br&gt;                                           "Initial Catalog=Northwind;" +&lt;br&gt;                                           "Data Source=hempc\\SQLExpress";&lt;br&gt;         DataSet thisDataSet = new DataSet();&lt;br&gt;         SqlDataAdapter custAdapter = new SqlDataAdapter&lt;br&gt;            ("Select * from customers", thisConnection);&lt;br&gt;         custAdapter.Fill(thisDataSet, "Customers");&lt;br&gt;         this.dataGridViewCustomer.DataSource = thisDataSet;&lt;br&gt;         this.dataGridViewCustomer.Refresh();&lt;br&gt;      }&lt;br&gt;   }&lt;br&gt;&lt;br&gt;   partial class Form1&lt;br&gt;   {&lt;br&gt;      private System.ComponentModel.IContainer components = null;&lt;br&gt;      protected override void Dispose(bool disposing)&lt;br&gt;      {&lt;br&gt;         if (disposing &amp;&amp; (components != null))&lt;br&gt;         {&lt;br&gt;            components.Dispose();&lt;br&gt;         }&lt;br&gt;         base.Dispose(disposing);&lt;br&gt;      }&lt;br&gt;&lt;br&gt;      #region Windows Form Designer generated code&lt;br&gt;      private void InitializeComponent()&lt;br&gt;      {&lt;br&gt;         this.dataGridViewCustomer = new &lt;br&gt;System.Windows.Forms.DataGridView();&lt;br&gt;         ((System.ComponentModel.ISupportInitialize)(this.dataGridViewCustomer)).BeginInit();&lt;br&gt;         this.SuspendLayout();&lt;br&gt;         this.dataGridViewCustomer.ColumnHeadersHeightSizeMode = &lt;br&gt;System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;&lt;br&gt;         this.dataGridViewCustomer.Location = new System.Drawing.Point(25, &lt;br&gt;24);&lt;br&gt;         this.dataGridViewCustomer.Name = "dataGridViewCustomer";&lt;br&gt;         this.dataGridViewCustomer.Size = new System.Drawing.Size(506, 342);&lt;br&gt;         this.dataGridViewCustomer.TabIndex = 0;&lt;br&gt;         this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);&lt;br&gt;         this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;&lt;br&gt;         this.ClientSize = new System.Drawing.Size(543, 408);&lt;br&gt;         this.Controls.Add(this.dataGridViewCustomer);&lt;br&gt;         this.Name = "Form1";&lt;br&gt;         this.Text = "Form1";&lt;br&gt;         ((System.ComponentModel.ISupportInitialize)(this.dataGridViewCustomer)).EndInit();&lt;br&gt;         this.ResumeLayout(false);&lt;br&gt;      }&lt;br&gt;      #endregion&lt;br&gt;      private System.Windows.Forms.DataGridView dataGridViewCustomer;&lt;br&gt;   }&lt;br&gt;&lt;br&gt;//Tony &lt;br&gt;&lt;br&gt;</description><pubDate>Sat, 04 Jul 2009 11:10:17 GMT</pubDate><category>C# newsgroup post</category><dc:creator>"Tony Johansson" &lt;johansson.andersson@telia.com&gt;</dc:creator></item><item><title>Re: Setting and Retrieving MySQL BIT(1) datatype as boolean value</title><guid isPermaLink="false" /><description>ng01@gvn.com wrote:&lt;br&gt;&gt; What would the proper parameter statement be to insert a true or false&lt;br&gt;&gt; into a MySQL (version 5.1.31) BIT(1) field?  Here is what I have:&lt;br&gt;&gt; &lt;br&gt;&gt; Cmd.Parameters.Add("@USCurrency", OdbcType.Bit).Value = 0;&lt;br&gt;&gt; &lt;br&gt;&gt; And what would be the proper select statement to retrieve a true or&lt;br&gt;&gt; false from that field?&lt;br&gt;&gt; Here is what I'm trying, but it always returns a True (when I browse&lt;br&gt;&gt; the datatable in the debugger):&lt;br&gt;&gt; &lt;br&gt;&gt; DataTable dt = GetTable2("select USCurrency from tblquotesnew");&lt;br&gt;&gt; &lt;br&gt;&gt; I've tried every OdbcType, with various values, both numeric and&lt;br&gt;&gt; string, to no avail.  It always comes back True.&lt;br&gt;&gt; &lt;br&gt;&gt; Thanks very much for any ideas.&lt;br&gt;&lt;br&gt;&lt;br&gt;Try DataTable dt = GetTable2("select USCurrency from tblquotesnew where &lt;br&gt;USCurrency = 1");</description><pubDate>Sat, 04 Jul 2009 10:51:27 +0100</pubDate><category>C# newsgroup post</category><dc:creator>Peter Kane &lt;pete@pjksolutions.com&gt;</dc:creator></item><item><title>Setting and Retrieving MySQL BIT(1) datatype as boolean value</title><guid isPermaLink="false" /><description>What would the proper parameter statement be to insert a true or false&lt;br&gt;into a MySQL (version 5.1.31) BIT(1) field?  Here is what I have:&lt;br&gt;&lt;br&gt;Cmd.Parameters.Add("@USCurrency", OdbcType.Bit).Value = 0;&lt;br&gt;&lt;br&gt;And what would be the proper select statement to retrieve a true or&lt;br&gt;false from that field?&lt;br&gt;Here is what I'm trying, but it always returns a True (when I browse&lt;br&gt;the datatable in the debugger):&lt;br&gt;&lt;br&gt;DataTable dt = GetTable2("select USCurrency from tblquotesnew");&lt;br&gt;&lt;br&gt;I've tried every OdbcType, with various values, both numeric and&lt;br&gt;string, to no avail.  It always comes back True.&lt;br&gt;&lt;br&gt;Thanks very much for any ideas.</description><pubDate>Sat, 4 Jul 2009 00:47:11 -0700 (PDT)</pubDate><category>C# newsgroup post</category><dc:creator>ng01@gvn.com</dc:creator></item><item><title>Re: Styling controls</title><guid isPermaLink="false" /><description>Many are created as user controls and using GDI+ among other things&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;"Sweetiecakes" &lt;x@x.com&gt; wrote in message &lt;br&gt;news:4a4e3251$0$26363$9b536df3@news.fv.fi:&lt;br&gt;&lt;br&gt;&gt; Hi&lt;br&gt;&gt;&lt;br&gt;&gt; How are packages like DotNetBar and such created? I'd like to have a&lt;br&gt;&gt; better looking TreeView, but I don't think I'm very willing to dish out&lt;br&gt;&gt; 800$ on one...&lt;br&gt;&gt;&lt;br&gt;&gt; How are those controls created?&lt;br&gt;</description><pubDate>Sat, 4 Jul 2009 07:06:20 +0000</pubDate><category>C# newsgroup post</category><dc:creator>"Jon Masterson" &lt;jon@scruffyduck.co.uk&gt;</dc:creator></item><item><title>Re: a simple client example</title><guid isPermaLink="false" /><description>On Fri, 03 Jul 2009 21:29:16 -0700, Andreas Ott &lt;aok@dis.microsoft.com&gt;  &lt;br&gt;wrote:&lt;br&gt;&lt;br&gt;&gt; Good morning,&lt;br&gt;&gt;&gt;&gt; My is not working.&lt;br&gt;&gt;&gt;&gt;&lt;br&gt;&gt;&gt;&gt; Every time I receive a exception.&lt;br&gt;&gt;&gt;&gt;             catch (Exception e)&lt;br&gt;&gt;&gt;&gt;             {&lt;br&gt;&gt;&gt;&gt;                 Console.WriteLine(e.Message);&lt;br&gt;&gt; here!&lt;br&gt;&lt;br&gt;No.  That's where the exception is _caught_, not thrown.&lt;br&gt;&lt;br&gt;&gt;&gt;&gt;             }&lt;br&gt;&gt;&gt;  What exception ? In what line ?&lt;br&gt;&gt;&gt;&lt;br&gt;&gt;&lt;br&gt;&gt; 		Message	"No connection"	&lt;br&gt;&gt; 		ErrorCode	10061	int&lt;br&gt;&lt;br&gt;Just looking at the code, I'd say one possible problem is that you don't  &lt;br&gt;understand the NetworkStream.Read() method.  In particular, while your  &lt;br&gt;first comment states correctly that the return value will be "anything  &lt;br&gt; from 0 to numBytesToRead", the second comment incorrectly states that the  &lt;br&gt;"method blocks until at least one byte is read", and you fail to check for  &lt;br&gt;a 0 return value, indicating the end-of-stream.&lt;br&gt;&lt;br&gt;And if you try to read from a socket once it's reached the end-of-stream,  &lt;br&gt;it's entirely possible you'd get the "no connection" exception you're  &lt;br&gt;seeing.&lt;br&gt;&lt;br&gt;If that doesn't help you fix your code, then you need to provide a more  &lt;br&gt;complete example.  In particular, seeing the client side code isn't  &lt;br&gt;sufficient; there's no way to be sure we can reproduce the problem unless  &lt;br&gt;you provide enough information to use that client code with some specific  &lt;br&gt;server.  I.e. either provide the server code itself, or provide the  &lt;br&gt;necessary command line arguments that one would require in order to  &lt;br&gt;connect to an appropriate server.&lt;br&gt;&lt;br&gt;Pete</description><pubDate>Fri, 03 Jul 2009 23:11:27 -0700</pubDate><category>C# newsgroup post</category><dc:creator>"Peter Duniho" &lt;no.peted.spam@no.nwlink.spam.com&gt;</dc:creator></item><item><title>Re: a simple client example</title><guid isPermaLink="false" /><description>Good morning,&lt;br&gt;&gt;&gt; My is not working.&lt;br&gt;&gt;&gt;&lt;br&gt;&gt;&gt; Every time I receive a exception.&lt;br&gt;&gt;&gt;             catch (Exception e)&lt;br&gt;&gt;&gt;             {&lt;br&gt;&gt;&gt;                 Console.WriteLine(e.Message);&lt;br&gt;here!&lt;br&gt;&gt;&gt;             }&lt;br&gt;&gt; &lt;br&gt;&gt; What exception ? In what line ?&lt;br&gt;&gt; &lt;br&gt;&lt;br&gt;		Message	"No connection"	&lt;br&gt;		ErrorCode	10061	int&lt;br&gt;&lt;br&gt;&lt;br&gt;Regards Andreas&lt;br&gt;</description><pubDate>Sat, 04 Jul 2009 06:29:16 +0200</pubDate><category>C# newsgroup post</category><dc:creator>Andreas Ott &lt;aok@dis.microsoft.com&gt;</dc:creator></item><item><title>Re: a simple client example</title><guid isPermaLink="false" /><description>Andreas Ott wrote:&lt;br&gt;&gt; I looking for a simple client example.&lt;br&gt;&gt; My is not working.&lt;br&gt;&gt; &lt;br&gt;&gt; Every time I receive a exception.&lt;br&gt;&gt;             catch (Exception e)&lt;br&gt;&gt;             {&lt;br&gt;&gt;                 Console.WriteLine(e.Message);&lt;br&gt;&gt;             }&lt;br&gt;&lt;br&gt;What exception ? In what line ?&lt;br&gt;&lt;br&gt;Arne</description><pubDate>Fri, 03 Jul 2009 20:45:53 -0400</pubDate><category>C# newsgroup post</category><dc:creator>=?ISO-8859-15?Q?Arne_Vajh=F8j?= &lt;arne@vajhoej.dk&gt;</dc:creator></item><item><title>Re: Styling controls</title><guid isPermaLink="false" /><description>I don't know, I'm very ignorant, what anbout silverligth?&lt;br&gt;&lt;br&gt;I hope my comment could be useful for something&lt;br&gt;&lt;br&gt;&lt;br&gt;"Sweetiecakes" &lt;x@x.com&gt; escribis en el mensaje &lt;br&gt;news:4a4e3251$0$26363$9b536df3@news.fv.fi...&lt;br&gt;&gt; Hi&lt;br&gt;&gt;&lt;br&gt;&gt; How are packages like DotNetBar and such created? I'd like to have a&lt;br&gt;&gt; better looking TreeView, but I don't think I'm very willing to dish out&lt;br&gt;&gt; 800$ on one...&lt;br&gt;&gt;&lt;br&gt;&gt; How are those controls created? &lt;br&gt;&lt;br&gt;</description><pubDate>Fri, 3 Jul 2009 19:26:25 -0500</pubDate><category>C# newsgroup post</category><dc:creator>"fx" &lt;no@mail&gt;</dc:creator></item><item><title>Communication with threads</title><guid isPermaLink="false" /><description>Hello NG&lt;br&gt;&lt;br&gt;I have found some code about TAPI, this set me going to implement TAPI in my &lt;br&gt;Application.&lt;br&gt;The TAPI i made in two classes within my application.&lt;br&gt;The Main Class TAPIComponent initializes the Tapi (Using the Microsoft &lt;br&gt;Tapi3) and the second class is the Event class for the TAPIComponent.&lt;br&gt;&lt;br&gt;On The Event class i have a Delegate DetectCallHandler(string CallerID) and &lt;br&gt;DetectCall Event that is called from the TAPIComponent.&lt;br&gt;On the TAPIComponent I have a Delegate IncommingCallHandler(string CallerID) &lt;br&gt;and IncommingCall Event, that is called within my Application - like&lt;br&gt;&lt;br&gt;TAPIComponent tapiCom = new TAPIComponent();&lt;br&gt;tapiCom.IncommingCall += new &lt;br&gt;TAPIComponent.IncommingCallHandler(tapi_IncommingCall);&lt;br&gt;&lt;br&gt;So, when the TAPI device detect a call i raises the event DetectCall - in &lt;br&gt;that event the event IncommingCall is raised and by that i'll get the caller &lt;br&gt;id into my application.&lt;br&gt;&lt;br&gt;All above works just fine.&lt;br&gt;&lt;br&gt;In my application in the event tapi_IncommingCall I want to display a &lt;br&gt;winform (TAPINotify) with information on the CallerID, and some buttons that &lt;br&gt;opens other winforms.&lt;br&gt;&lt;br&gt;Already when I want to open the TAPINotify form is gets (not responding) and &lt;br&gt;if i open the form with the parameter TAPINotify.MDIParent = DesktopForm &lt;br&gt;i'll get the exception about not able to open form from other thread?&lt;br&gt;Then I tryed to open that TAPINotify in another Thread - OK fine it worked. &lt;br&gt;But now when i wanted to open forms from the TAPINotify form i'll got the &lt;br&gt;same error from before, because the form i open must have the MDIParent set &lt;br&gt;to my desktop form.&lt;br&gt;&lt;br&gt;Can someone tell me what to do.&lt;br&gt;&lt;br&gt;Kind regards&lt;br&gt;J E Jensen &lt;br&gt;&lt;br&gt;</description><pubDate>Sat, 4 Jul 2009 01:48:41 +0200</pubDate><category>C# newsgroup post</category><dc:creator>"JJ" &lt;jj@jj.jj&gt;</dc:creator></item><item><title>Re: GZipStream catch-22</title><guid isPermaLink="false" /><description>bamelyan wrote:&lt;br&gt;&gt; GZipStream unzip = new GZipStream(stream, CompressionMode.Decompress, false);&lt;br&gt;&gt; &lt;br&gt;&gt; In order to read from unzip.Read(buffer, 0, unknownLength), I need to &lt;br&gt;&gt; allocate enough buffer length.&lt;br&gt;&gt; In order to know how many bytes to allocate I need to call &lt;br&gt;&gt; unzip.Read(buffer, 0, unknownLength) that returns bytes.&lt;br&gt;&gt; &lt;br&gt;&gt; How do i get unknownLength to allocate buffer before the Read?&lt;br&gt;&lt;br&gt;Just pick a buffer size (like 51200) and read in a while&lt;br&gt;loop and process the data as they come in.&lt;br&gt;&lt;br&gt;If you need to keep all the data in a buffer in memory, then&lt;br&gt;you will need to either know the maximum size or copy over&lt;br&gt;to a larger buffer when needed.&lt;br&gt;&lt;br&gt;You can know how many bytes if the protocol somehow sends&lt;br&gt;the uncompressed length before the gzipped data.&lt;br&gt;&lt;br&gt;If the data is "normal", then creating a buffer 10 times as&lt;br&gt;big as the compressed data and copy to a new larger buffer&lt;br&gt;inside the while loop if necessary should be fine in the sense&lt;br&gt;that the chance of having to copy data would be very small.&lt;br&gt;&lt;br&gt;Arne&lt;br&gt;&lt;br&gt;</description><pubDate>Fri, 03 Jul 2009 19:07:07 -0400</pubDate><category>C# newsgroup post</category><dc:creator>=?UTF-8?B?QXJuZSBWYWpow7hq?= &lt;arne@vajhoej.dk&gt;</dc:creator></item><item><title>Re: Is MemoryStream compressed?</title><guid isPermaLink="false" /><description>bamelyan wrote:&lt;br&gt;&gt; "Arne VajhC8j" wrote:&lt;br&gt;&gt;&gt; bamelyan wrote:&lt;br&gt;&gt;&gt;&gt; Is there a way to determine wether a MemoryStream is compressed, i.e. needs &lt;br&gt;&gt;&gt;&gt; to be decompressed with GZipStream?   &lt;br&gt;&gt;&gt; Not really.&lt;br&gt;&gt;&gt;&lt;br&gt;&gt;&gt; Bytes are just bytes.&lt;br&gt;&gt;&gt;&lt;br&gt;&gt;&gt; If the first 3 bytes are 0x1f 0x8b 0x08 then there is a decent chance&lt;br&gt;&gt;&gt; it is gzipped.&lt;br&gt; &gt; thanks for quick response.  what's the expected behavior of &lt;br&gt;GZipStream if i&lt;br&gt; &gt; try to decompress a stream that is not compressed?&lt;br&gt;&lt;br&gt;I think one of two will happen:&lt;br&gt;* if the data just happens to be a valid GZIP format then you&lt;br&gt;   will get absolute garbage&lt;br&gt;* else (and that is by far the most likely) then you will&lt;br&gt;   get a InvalidDataException&lt;br&gt;&lt;br&gt;Arne</description><pubDate>Fri, 03 Jul 2009 19:02:51 -0400</pubDate><category>C# newsgroup post</category><dc:creator>=?UTF-8?B?QXJuZSBWYWpow7hq?= &lt;arne@vajhoej.dk&gt;</dc:creator></item><item><title>Re: GZipStream catch-22</title><guid isPermaLink="false" /><description>bamelyan wrote:&lt;br&gt;&gt; GZipStream unzip = new GZipStream(stream, CompressionMode.Decompress, false);&lt;br&gt;&gt; &lt;br&gt;&gt; In order to read from unzip.Read(buffer, 0, unknownLength), I need to &lt;br&gt;&gt; allocate enough buffer length.&lt;br&gt;&gt; In order to know how many bytes to allocate I need to call &lt;br&gt;&gt; unzip.Read(buffer, 0, unknownLength) that returns bytes.&lt;br&gt;&gt; &lt;br&gt;Not at all. Any buffer size that's not 0 will do. The Read() method returns &lt;br&gt;the number of bytes actually read. If it's 0, you're at the end of the &lt;br&gt;stream. If not, your buffer contains valid data from index 0 up to whatever &lt;br&gt;it returned (this may not fill your buffer entirely, even when not at the &lt;br&gt;end of the stream). Process this data in whatever way you want (for example, &lt;br&gt;by appending it to a MemoryStream you're going to read in its entirety &lt;br&gt;later), rinse, repeat.&lt;br&gt;&lt;br&gt;All streams work this way, not just GZipStream.&lt;br&gt;&lt;br&gt;&gt; How do i get unknownLength to allocate buffer before the Read?&lt;br&gt;&lt;br&gt;Pick any length. Let's say 1024 because it's a nice round number, and it's &lt;br&gt;what BufferedStream uses by default. (Using BufferedStream and .ReadByte() &lt;br&gt;is another option -- not as efficient as calling .Read() yourself, but by &lt;br&gt;far more efficient than calling .ReadByte() on GZipStream directly.)&lt;br&gt;&lt;br&gt;-- &lt;br&gt;J.</description><pubDate>Sat, 04 Jul 2009 00:05:45 +0200</pubDate><category>C# newsgroup post</category><dc:creator>Jeroen Mostert &lt;jmostert@xs4all.nl&gt;</dc:creator></item><item><title>Re: GZipStream catch-22</title><guid isPermaLink="false" /><description>bamelyan wrote:&lt;br&gt;&gt; GZipStream unzip = new GZipStream(stream, CompressionMode.Decompress, false);&lt;br&gt;&gt; &lt;br&gt;&gt; In order to read from unzip.Read(buffer, 0, unknownLength), I need to &lt;br&gt;&gt; allocate enough buffer length.&lt;br&gt;&gt; In order to know how many bytes to allocate I need to call &lt;br&gt;&gt; unzip.Read(buffer, 0, unknownLength) that returns bytes.&lt;br&gt;&gt; &lt;br&gt;&gt; How do i get unknownLength to allocate buffer before the Read?&lt;br&gt;&lt;br&gt;unknownLength is the size of your buffer.  It is not really "unknown". &lt;br&gt;The bytes returned will be less than or equal to the value sent into the &lt;br&gt;call.  It seems as though you may be interpreting the call is asking for &lt;br&gt;the number of bytes in the compressed stream, which is incorrect.&lt;br&gt;&lt;br&gt;--------------------&lt;br&gt;Mike</description><pubDate>Fri, 03 Jul 2009 17:55:01 -0400</pubDate><category>C# newsgroup post</category><dc:creator>Family Tree Mike &lt;FamilyTreeMike@ThisOldHouse.com&gt;</dc:creator></item><item><title>GZipStream catch-22</title><guid isPermaLink="false" /><description>GZipStream unzip = new GZipStream(stream, CompressionMode.Decompress, false);&lt;br&gt;&lt;br&gt;In order to read from unzip.Read(buffer, 0, unknownLength), I need to &lt;br&gt;allocate enough buffer length.&lt;br&gt;In order to know how many bytes to allocate I need to call &lt;br&gt;unzip.Read(buffer, 0, unknownLength) that returns bytes.&lt;br&gt;&lt;br&gt;How do i get unknownLength to allocate buffer before the Read?</description><pubDate>Fri, 3 Jul 2009 14:44:01 -0700</pubDate><category>C# newsgroup post</category><dc:creator>=?Utf-8?B?YmFtZWx5YW4=?= &lt;bamelyan@discussions.microsoft.com&gt;</dc:creator></item><item><title>Re: Is MemoryStream compressed?</title><guid isPermaLink="false" /><description>thanks for quick response.  what's the expected behavior of GZipStream if i &lt;br&gt;try to decompress a stream that is not compressed?&lt;br&gt;&lt;br&gt;"Arne VajhC8j" wrote:&lt;br&gt;&lt;br&gt;&gt; bamelyan wrote:&lt;br&gt;&gt; &gt; Is there a way to determine wether a MemoryStream is compressed, i.e. needs &lt;br&gt;&gt; &gt; to be decompressed with GZipStream?   &lt;br&gt;&gt; &lt;br&gt;&gt; Not really.&lt;br&gt;&gt; &lt;br&gt;&gt; Bytes are just bytes.&lt;br&gt;&gt; &lt;br&gt;&gt; If the first 3 bytes are 0x1f 0x8b 0x08 then there is a decent chance&lt;br&gt;&gt; it is gzipped.&lt;br&gt;&gt; &lt;br&gt;&gt; Arne&lt;br&gt;&gt; </description><pubDate>Fri, 3 Jul 2009 14:31:01 -0700</pubDate><category>C# newsgroup post</category><dc:creator>=?Utf-8?B?YmFtZWx5YW4=?= &lt;bamelyan@discussions.microsoft.com&gt;</dc:creator></item><item><title>Re: Is MemoryStream compressed?</title><guid isPermaLink="false" /><description>bamelyan wrote:&lt;br&gt;&gt; Is there a way to determine wether a MemoryStream is compressed, i.e. needs &lt;br&gt;&gt; to be decompressed with GZipStream?   &lt;br&gt;&lt;br&gt;Not really.&lt;br&gt;&lt;br&gt;Bytes are just bytes.&lt;br&gt;&lt;br&gt;If the first 3 bytes are 0x1f 0x8b 0x08 then there is a decent chance&lt;br&gt;it is gzipped.&lt;br&gt;&lt;br&gt;Arne</description><pubDate>Fri, 03 Jul 2009 16:45:04 -0400</pubDate><category>C# newsgroup post</category><dc:creator>=?UTF-8?B?QXJuZSBWYWpow7hq?= &lt;arne@vajhoej.dk&gt;</dc:creator></item><item><title>a simple client example</title><guid isPermaLink="false" /><description>Hello,&lt;br&gt;&lt;br&gt;I looking for a simple client example.&lt;br&gt;My is not working.&lt;br&gt;&lt;br&gt;Every time I receive a exception.&lt;br&gt;             catch (Exception e)&lt;br&gt;             {&lt;br&gt;                 Console.WriteLine(e.Message);&lt;br&gt;             }&lt;br&gt;&lt;br&gt;My goal is.&lt;br&gt;     I need a client for receive data, without limit for logging.&lt;br&gt;      The client is / must be every time on state --- receive&lt;br&gt;&lt;br&gt;Can somebody help me.&lt;br&gt;&lt;br&gt;&lt;br&gt;Thanks.&lt;br&gt;&lt;br&gt;Regards&lt;br&gt;  Andreas&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;class Program&lt;br&gt;     {&lt;br&gt;         static void Main(string[] args)&lt;br&gt;         {&lt;br&gt;             if ((args.Length &lt; 1) || (args.Length &gt; 3))&lt;br&gt;             {&lt;br&gt;                 throw new ArgumentException("Parameters: &lt;Word&gt; &lt;br&gt;[&lt;Server&gt;] [&lt;Port&gt;]");&lt;br&gt;             }&lt;br&gt;&lt;br&gt;             byte[] byteBuffer = Encoding.ASCII.GetBytes(args[0]);&lt;br&gt;&lt;br&gt;&lt;br&gt;             string server = (args.Length == 1) ? args[0].ToString() : &lt;br&gt;Dns.GetHostName();&lt;br&gt;&lt;br&gt;             int servPort = (args.Length == 2) ? Int32.Parse(args[1]) : 7;&lt;br&gt;&lt;br&gt;             TcpClient tcpClient = null;&lt;br&gt;             NetworkStream netStream = null;&lt;br&gt;&lt;br&gt;             try&lt;br&gt;             {&lt;br&gt;                 tcpClient = new TcpClient(server, servPort);&lt;br&gt;&lt;br&gt;                 // Uses the GetStream public method to return the &lt;br&gt;NetworkStream.&lt;br&gt;                  netStream = tcpClient.GetStream();&lt;br&gt;&lt;br&gt;                 //if (netStream.CanWrite)&lt;br&gt;                 //{&lt;br&gt;                 //    Byte[] sendBytes = Encoding.UTF8.GetBytes("Is &lt;br&gt;anybody there?");&lt;br&gt;                 //   // netStream.Write(sendBytes, 0, sendBytes.Length);&lt;br&gt;                 //}&lt;br&gt;                 //else&lt;br&gt;                 //{&lt;br&gt;                 //    Console.WriteLine("You cannot write data to this &lt;br&gt;stream.");&lt;br&gt;                 //    tcpClient.Close();&lt;br&gt;&lt;br&gt;                 //    // Closing the tcpClient instance does not close &lt;br&gt;the network stream.&lt;br&gt;                 //    netStream.Close();&lt;br&gt;                 //    return;&lt;br&gt;                 //}&lt;br&gt;&lt;br&gt;                  while (true)&lt;br&gt;                  {&lt;br&gt;                      if (netStream.CanRead)&lt;br&gt;                      {&lt;br&gt;                          // Reads NetworkStream into a byte buffer.&lt;br&gt;                          byte[] bytes = new &lt;br&gt;byte[tcpClient.ReceiveBufferSize];&lt;br&gt;&lt;br&gt;                          // Read can return anything from 0 to &lt;br&gt;numBytesToRead.&lt;br&gt;                          // This method blocks until at least one byte &lt;br&gt;is read.&lt;br&gt;                          netStream.Read(bytes, 0, &lt;br&gt;(int)tcpClient.ReceiveBufferSize);&lt;br&gt;&lt;br&gt;                          // Returns the data received from the host to &lt;br&gt;the console.&lt;br&gt;                          string returndata = &lt;br&gt;Encoding.UTF8.GetString(bytes);&lt;br&gt;&lt;br&gt;                          Console.WriteLine("This is what the host &lt;br&gt;returned to you: " + returndata);&lt;br&gt;&lt;br&gt;                      }&lt;br&gt;                  }&lt;br&gt;                 //else&lt;br&gt;                 //{&lt;br&gt;                     Console.WriteLine("You cannot read data from this &lt;br&gt;stream.");&lt;br&gt;                     tcpClient.Close();&lt;br&gt;&lt;br&gt;                     // Closing the tcpClient instance does not close &lt;br&gt;the network stream.&lt;br&gt;                     netStream.Close();&lt;br&gt;                     return;&lt;br&gt;                 //}&lt;br&gt;                 //netStream.Close();&lt;br&gt;             }&lt;br&gt;             catch (Exception e)&lt;br&gt;             {&lt;br&gt;                 Console.WriteLine(e.Message);&lt;br&gt;             }&lt;br&gt;             finally&lt;br&gt;             {&lt;br&gt;&lt;br&gt;             }&lt;br&gt;         }&lt;br&gt;     }</description><pubDate>Fri, 03 Jul 2009 22:43:08 +0200</pubDate><category>C# newsgroup post</category><dc:creator>Andreas Ott &lt;aok@dis.microsoft.com&gt;</dc:creator></item><item><title>Re: ASCII to hex/binary</title><guid isPermaLink="false" /><description>TNCoder wrote:&lt;br&gt;&gt; I have an ASCII string. For example:&lt;br&gt;&gt; string myString = "1200B2C4D2BB9863";&lt;br&gt;&gt; I need to convert this to byte[] 0x1200B2C4D2BB9863;&lt;br&gt;&gt; &lt;br&gt;&gt; Are there any suggestions?&lt;br&gt;&lt;br&gt;Straight:&lt;br&gt;&lt;br&gt;         public static byte[] XParse(string s)&lt;br&gt;         {&lt;br&gt;             byte[] ba = new byte[s.Length / 2];&lt;br&gt;             for(int i = 0; i &lt; ba.Length; i++)&lt;br&gt;             {&lt;br&gt;                 ba[i] = byte.Parse(s.Substring(2 * i, 2), &lt;br&gt;NumberStyles.HexNumber);&lt;br&gt;             }&lt;br&gt;             return ba;&lt;br&gt;         }&lt;br&gt;&lt;br&gt;Arne</description><pubDate>Fri, 03 Jul 2009 16:17:57 -0400</pubDate><category>C# newsgroup post</category><dc:creator>=?UTF-8?B?QXJuZSBWYWpow7hq?= &lt;arne@vajhoej.dk&gt;</dc:creator></item><item><title>Re: get current platform (x86, x64)</title><guid isPermaLink="false" /><description>Family Tree Mike wrote:&lt;br&gt;&gt; Michael Covington wrote:&lt;br&gt;&gt;&gt; Frank Uray wrote:&lt;br&gt;&gt;&gt;&gt; I am using "Any CPU" within my assemblies.&lt;br&gt;&gt;&gt;&gt; Is there a way to find out which platform is used ?&lt;br&gt;&gt;&gt;&gt; I like to know where the assembly is running on (x86, x64) ...&lt;br&gt;&gt;&gt;&gt;&lt;br&gt;&gt;&gt;&gt; Thanks for any comments&lt;br&gt;&gt;&gt;&gt; and best regards&lt;br&gt;&gt;&gt;&gt; Frank Uray&lt;br&gt;&gt;&gt;&lt;br&gt;&gt;&gt; If nothing else, there should be a WMI call to tell you about this.  &lt;br&gt;&gt;&gt; For something related, see:&lt;br&gt;&gt;&gt;&lt;br&gt;&gt;&gt; http://www.covingtoninnovations.com/michael/blog/0807/index.html#080710&lt;br&gt;&gt;&gt;&lt;br&gt;&gt;&gt; However, there may be a way to do it within .NET.  Ideas, anyone?&lt;br&gt;&gt; &lt;br&gt;&gt; The size of IntPtr will be 8 under x64, and 4 under x86.&lt;br&gt;&gt; &lt;br&gt;&gt; Console.WriteLine(IntPtr.Size == 4 ? "x86" : "x64");&lt;br&gt;&lt;br&gt;Assuming that it is 32/64 bit of the CLR and not of Windows, then&lt;br&gt;that must be the easiest.&lt;br&gt;&lt;br&gt;Arne</description><pubDate>Fri, 03 Jul 2009 16:09:50 -0400</pubDate><category>C# newsgroup post</category><dc:creator>=?UTF-8?B?QXJuZSBWYWpow7hq?= &lt;arne@vajhoej.dk&gt;</dc:creator></item></channel></rss>