Beispiel #1
0
        public static void WritePinyinDat()
        {
            var          fs = File.Open("Pinyin.dat", FileMode.Create);
            BinaryWriter bw = new BinaryWriter(fs);

            bw.Write(_pyName.Count);
            foreach (var item in _pyName)
            {
                bw.Write(item.Key);
                var bs2 = IntArrToByteArr(item.Value);
                bw.Write(bs2.Length);
                bw.Write(bs2);
            }
            bw.Write(_pyShow.Length);
            foreach (var item in _pyShow)
            {
                bw.Write(item);
            }

            var bt = IntArrToByteArr(_pyIndex);

            bw.Write(bt.Length);
            bw.Write(bt);

            bt = IntArrToByteArr(_pyData);
            bw.Write(bt.Length);
            bw.Write(bt);

            bt = IntArrToByteArr(_wordPyIndex);
            bw.Write(bt.Length);
            bw.Write(bt);

            bt = IntArrToByteArr(_wordPy);
            bw.Write(bt.Length);
            bw.Write(bt);

            _search.SaveFile(bw);

            bw.Close();
            fs.Close();
        }
Beispiel #2
0
        private byte[] WritePinyinDat()
        {
            MemoryStream ms = new MemoryStream();
            BinaryWriter bw = new BinaryWriter(ms);

            bw.Write(_pyName.Count);
            foreach (var item in _pyName)
            {
                bw.Write(item.Key);
                var bs2 = IntArrToByteArr(item.Value);
                bw.Write(bs2.Length);
                bw.Write(bs2);
            }
            bw.Write(_pyShow.Length);
            foreach (var item in _pyShow)
            {
                bw.Write(item);
            }

            var bt = IntArrToByteArr(_pyIndex);

            bw.Write(bt.Length);
            bw.Write(bt);

            bt = IntArrToByteArr(_pyData);
            bw.Write(bt.Length);
            bw.Write(bt);

            bt = IntArrToByteArr(_wordPyIndex);
            bw.Write(bt.Length);
            bw.Write(bt);

            bt = IntArrToByteArr(_wordPy);
            bw.Write(bt.Length);
            bw.Write(bt);

            _search.SaveFile(bw);

            bw.Close();
            return(ms.ToArray());
        }