I am using visual c# to create a windows chat app, and I want all the :) words inside the chatDisplay rich text box to be replaced with a smiley image located in the resources folder. this is my code:
private void add_smileys()
{
if (chatDisplay.Text.Contains(":)"))
{
chatDisplay.SelectionStart = chatDisplay.Find(":)", RichTextBoxFinds.WholeWord);
chatDisplay.SelectionLength = 2;
String image = System.IO.Path.Combine(System.Windows.Forms.Application.StartupPath, "Resources/smile.png");
Image img = Image.FromFile(image);
Clipboard.SetImage(img);
chatDisplay.Paste();
Console.WriteLine("All images replaced");
}
}
I don't get any errors, and I don't get the "file not found" error either, and the "All images replaced" center is outputted in the console correctly. the only wrong thing is that the :) phrase in the textbox doesn't get replaced with the image. can someone help me? what's wrong with my code?