如果用读取文本的方式(读到sting里)读取这些乱码,再写到一个新创建的文件中,用文本打开,此乱码和彼乱码是一样的吗?还是乱码都是随机的?

解决方案 »

  1.   

    /// <summary>
      /// </summary>
            /// <param name="path">路径</param>
            public string[] readTxtFile(string path)
            {
                string[] s = new string[100];
                if (!File.Exists(path))
                { return null;}                          
                int iLength = 0;
                using (StreamReader sr = File.OpenText(path))
                {
                    while ((s[iLength] = sr.ReadLine()) != null)
                    { ++iLength; }
                }  
                string[] sReturn = new string[iLength];
                for (int i = 0; i <= iLength - 1; i++)
                { sReturn[i] = s[i]; }                  
                return sReturn;
            }
    /// <summary>
            /// 读文本直接放到CMBOX
            /// </summary>
            /// <param name="cmb"></param>
            public void readTxtInCmbox(string path,System.Windows.Forms.ComboBox cmb)
            {
                if (!File.Exists(path))
                { return; }
                using (StreamReader sr = File.OpenText(path))
                {
                    string s;
                    while (( s = sr.ReadLine()) != null)
                    {
                        cmb.Items.Add(s);
                    }
                    if (cmb.Items.Count > 0) { cmb.SelectedIndex = 0; }
                }
            }
      

  2.   

    to wwwiii520(蝸牛啃骨頭)
    谢谢你的代码,的确从文本中看到的乱麻和combobox中的乱麻不一样。为什么呢?to Macosx(不要呢称)
    我只针对的是文本。我的理解是同样的二进制的数据,如果不能正常解析,那么在不同的文本表现出来的乱码是随机的。是吗?