当前位置: 首页>>代码示例>>C#>>正文


C# BinaryReaderEx.ReadString方法代码示例

本文整理汇总了C#中BinaryReaderEx.ReadString方法的典型用法代码示例。如果您正苦于以下问题:C# BinaryReaderEx.ReadString方法的具体用法?C# BinaryReaderEx.ReadString怎么用?C# BinaryReaderEx.ReadString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BinaryReaderEx的用法示例。


在下文中一共展示了BinaryReaderEx.ReadString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SHNFile

        public SHNFile(string path)
        {
            try
            {
                columns.Clear();
                this.Path = path;
                if (System.IO.Path.GetFileNameWithoutExtension(path).ToLower().Contains("textdata")) isTextData = true;
                BinaryReaderEx r = new BinaryReaderEx(File.OpenRead(path));
                if (path.EndsWith(".shn"))
                {
                    this.CryptHeader = r.ReadBytes(0x20);
                    data = r.ReadBytes(r.ReadInt32() - 0x24);
                }
                else
                    data = r.ReadBytes((int)r.Length);
                r.Close();
                if (Properties.Settings.Default.isNewCrypto == true)
                    this.Decrypt(data, 0, data.Length, true);
                else
                    this.Decrypt(data, 0, data.Length);
                r = new BinaryReaderEx(new MemoryStream(data));
                this.Header = r.ReadUInt32();

                //FileStream stream = new FileStream(System.IO.Path.GetDirectoryName(path) + "\\TestFile.dat", FileMode.Create);
                //stream.Write(data, 0, data.Length);
                //stream.Close();
                //return;

                if (!((this.Header == 0xcdcdcdcd) | (this.Header == 0)))
                {
                    //bleh, why check, unk.dat is useless, outspark uses other enc
                }
                //Parse columns
                this.RecordCount = r.ReadUInt32();
                this.DefaultRecordLength = r.ReadUInt32();
                this.ColumnCount = r.ReadUInt32();
                this.ColumnNames = new string[this.ColumnCount];
                this.ColumnTypes = new uint[this.ColumnCount];
                this.ColumnLengths = new int[this.ColumnCount];

                int num2 = 2;
                int unkCols = 0;
                for (uint i = 0; i < this.ColumnCount; i++)
                {
                    string str = r.ReadString(0x30);
                    // if (str.Length < 2) MessageBox.Show(str.Length.ToString());
                    uint num4 = r.ReadUInt32();
                    int num5 = r.ReadInt32();

                    SHNColumn col = new SHNColumn();
                    if (str.Length == 0)
                    {
                        str = "UnkCol" + unkCols.ToString();
                        unkCols++;
                    }
                    col.name = str;
                    col.Type = num4;
                    col.Lenght = num5;
                    columns.Add(col);
                    this.ColumnNames[i] = str;
                    this.ColumnTypes[i] = num4;
                    this.ColumnLengths[i] = num5;
                    num2 += num5;
                }
                if (num2 != this.DefaultRecordLength)
                {
                    throw new Exception("Wrong record lenght!");
                }
                //generate columns
                this.GenerateColumns(table, columns);
                //add data into rows
                this.ReadRows(r, table);
            }
            catch (Exception e)
            {
                Stream X = new FileStream("unk.dat", FileMode.OpenOrCreate);
                BinaryWriter lol = new BinaryWriter(X);
                lol.Write(data, 0, data.Length);
                lol.Close();
                throw new Exception("Unknown File Type -- dec to unk.dat Reason: " + e.Message);
            }
        }
开发者ID:Canic,项目名称:Project_Actis,代码行数:82,代码来源:SHNFile.cs

示例2: ReadRows

        private void ReadRows(BinaryReaderEx r, DataTable table)
        {
            object[] values = new object[columns.Count];
            for (uint i = 0; i < this.RecordCount; i++)
            {
                uint RowLength = r.ReadUInt16();
                for (int j = 0; j < columns.Count; j++)
                {
                    switch (this.columns[j].Type)
                    {
                        case 1:
                            values[j] = r.ReadByte();
                            break;

                        case 2:
                            values[j] = r.ReadUInt16();
                            break;

                        case 3:
                            values[j] = r.ReadUInt32();
                            break;

                        case 5:
                            values[j] = r.ReadSingle();
                            break;

                        case 9:
                            values[j] = r.ReadString(this.ColumnLengths[j]);
                            break;

                        case 11:
                            values[j] = r.ReadUInt32();
                            break;

                        case 12:
                            values[j] = r.ReadByte();
                            break;

                        case 13:
                            values[j] = r.ReadInt16();
                            break;

                        case 0x10:
                            values[j] = r.ReadByte();
                            break;

                        case 0x12:
                            values[j] = r.ReadUInt32();
                            break;

                        case 20:
                            values[j] = r.ReadSByte();
                            break;

                        case 0x15:
                            values[j] = r.ReadInt16();
                            break;

                        case 0x16:
                            values[j] = r.ReadInt32();
                            break;

                        case 0x18:
                            values[j] = r.ReadString(this.ColumnLengths[j]);
                            break;

                        case 0x1a: //unk lenght
                            values[j] = r.ReadString();
                            break;

                        case 0x1b:
                            values[j] = r.ReadUInt32();
                            break;
                    }
                }
                table.Rows.Add(values);
            }
        }
开发者ID:Canic,项目名称:Project_Actis,代码行数:78,代码来源:SHNFile.cs


注:本文中的BinaryReaderEx.ReadString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。