Click here to Skip to main content
15,169,249 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Please help me i am amateur programmer.
I have made an app that i can browse txt files with Greek characters inside and i can send it to thermal printer directly with ip.
My problem is the Greek characters printing something like symbols

What I have tried:

namespace SendFiles
    public partial class Form1 : Form
        public string SendingFilePath = string.Empty;
        private const int BufferSize = 1024;
        public Form1()

        private void Form1_Load(object sender, EventArgs e)

        private void btnBrowse_Click(object sender, EventArgs e)
            OpenFileDialog Dlg = new OpenFileDialog();
            Dlg.Filter = "All Files (*.*)|*.*";
            Dlg.CheckFileExists = true;
            Dlg.Title = "Choose a File";
            Dlg.InitialDirectory = @"C:\";
            if (Dlg.ShowDialog() == DialogResult.OK)
                SendingFilePath = Dlg.FileName;

        private void btnSend_Click(object sender, EventArgs e)
            if (SendingFilePath != string.Empty)
                SendTCP(SendingFilePath, txtIP.Text, Int32.Parse(txtPort.Text));
                MessageBox.Show("Select a file","Warning");
        public void SendTCP(string M, string IPA, Int32 PortN)
            byte[] SendingBuffer = null;
            TcpClient client = null;
            lblStatus.Text = "";
            NetworkStream netstream = null;
                client = new TcpClient(IPA, PortN);
                lblStatus.Text = "Connected to the Server...\n";
                netstream = client.GetStream();
                FileStream Fs = new FileStream(M, FileMode.Open, FileAccess.Read);
                int NoOfPackets = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(Fs.Length) / Convert.ToDouble(BufferSize)));
                progressBar1.Maximum = NoOfPackets;
                int TotalLength = (int)Fs.Length, CurrentPacketLength, counter = 0;
                for (int i = 0; i < NoOfPackets; i++)
                    if (TotalLength > BufferSize)
                        CurrentPacketLength = BufferSize;
                        TotalLength = TotalLength - CurrentPacketLength;
                        CurrentPacketLength = TotalLength;
                    SendingBuffer = new byte[CurrentPacketLength];
                    Fs.Read(SendingBuffer, 0, CurrentPacketLength);
                    netstream.Write(SendingBuffer, 0, (int)SendingBuffer.Length);
                    if (progressBar1.Value >= progressBar1.Maximum)
                        progressBar1.Value = progressBar1.Minimum;
                lblStatus.Text=lblStatus.Text+"Sent "+Fs.Length.ToString()+" bytes to the server";
            catch (Exception ex)

Updated 28-Jul-18 19:58pm

1 solution

My problem is the Greek characters printing something like symbols

The problem look like a mismatch between the printer settings and what you send to the printer.
I would particularly pay attention to characters encoding on both sides.
If your file include printer commands, the brand/model/language may matter too. But you did't gave details.
Member 11396175 29-Jul-18 5:18am
I have a simple file .txt with ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ/αβγδεζηθικλμνξοπρστυφχψω
my thermal printer is LK-T20EB SEWOO
Patrice T 29-Jul-18 9:07am
Use Improve question to update your question.
So that everyone can pay attention to this information.
Gerry Schmitz 29-Jul-18 7:32am
The documentation for your product sucks.

You should be able to "select a font" ... except it doesn't say what fonts are available; or how to make them available.

You can print "images" ... except there is nothing about that either.

You should have picked a "better" (documented) product; add another 6 months to your project.
Patrice T 29-Jul-18 9:08am
who are talking to ?
Gerry Schmitz 29-Jul-18 15:59pm
A confusing (for me) interface ...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900