Skip to content

Need C# code for following problem

Sujit Das

Sujit Das

Asked Jul 31, 2014, 11:56 PM EDT1 answer
Share
LinkedInX
I wanted to load contents of text files by using button to richtextbox.It is working for english language file but when I was looking for bengali text file its not working....i am giving my codes below..please help me..
 
C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;
//using itextsharp.text;
//using iTextsharp.text.pdf;
//using iTextsharp.text.pdf.parser;

namespace tokenizer
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Stream Mystream;
            OpenFileDialog openfiledialog1 = new OpenFileDialog();
            if (openfiledialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                if ((Mystream = openfiledialog1.OpenFile()) != null)
                {
                    string strfilname = openfiledialog1.FileName;
                    string filetext = File.ReadAllText(strfilname);
                    richTextBox1.Text = filetext;

                }
            }
        }
    }
}
 

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    is you file in Bengali language stored properly, e.g., is it using ANSI or Unicode.

    if it's ANSI, then please change to unicode. if problem is still unresolved, then try converting
    Code
    string str = System.Text.Encoding.Unicode.GetString(array);
    
    twitter @sumitjolly
    0