title: my messeging Desktop application does't work on wpf c#
body: <p>So Basically I'm working on this Desktop application using c# server and client and for some reason whenever I send a msg in chat it doesn't work for all users but when I send a private msg it's working and I'm not sure why.</p>
  <p>my server code:</p>
  <pre><code> if (e.MessageString.Contains(&quot;#&quot;))
              {
              if (e.MessageString.Substring(0, 3).Equals(&quot;All&quot;))
              {
                  if (!e.MessageString.Substring(4, 4).Equals(&quot;File&quot;))
                  {
                      
                      string toAll = e.MessageString.Substring(4, e.MessageString.Length - 4) + &quot;\n&quot;;
                      server.Broadcast(toAll);
  
                      txtStatus.Dispatcher.Invoke((Action)delegate ()
                      {
                          txtStatus.Text += toAll;
  
                      });
                  }
                  else
                  {
                      System.Windows.MessageBox.Show(&quot;Cannot send a file to everyone!&quot;);
                  }
              }
  </code></pre>
  <p>and this is my chat code:</p>
  <pre><code>private void btnSend_Click(object sender, RoutedEventArgs e)
      {
          System.Console.WriteLine(&quot;Send was clicked&quot;);
          if (btnConnect.IsEnabled)
          {
              System.Windows.MessageBox.Show(&quot;Please connect to the local server!&quot;);
          }
          else if (listbox.SelectedIndex != -1)
          {
              if (txtMessage.Text.Length &gt; 0 &amp;&amp; !ifFileSelected &amp;&amp; !txtMessage.Text.Equals(&quot; &quot;) &amp;&amp; !txtMessage.Text.Equals(&quot;\n&quot;))
              {
                  client.WriteLine(listbox.SelectedItem.ToString().ToLower() + &quot;#&quot; + username + &quot;: &quot; + txtMessage.Text);
              }
              else if (ifFileSelected)
              {
                  byte[] b1 = File.ReadAllBytes(op.FileName);
                  client.Write(listbox.SelectedItem.ToString() + &quot;#File#&quot; + fi.Name + &quot;#&quot;);
                  client.Write(b1);
                  ifFileSelected = false;
              }
              else
              {
                  System.Windows.MessageBox.Show(&quot;Please type something or choose a file to send!&quot;);
              }
          }
          else
          {
              System.Windows.MessageBox.Show(&quot;Please select someone to send the message to!&quot;);
          }
  
          txtMessage.Text = &quot;&quot;;
          
      }
  </code></pre>
  <p><a href="https://i.stack.imgur.com/su4rL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/su4rL.png" alt="enter image description here" /></a></p>