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


C# BigEndianBinaryReader.Close方法代码示例

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


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

示例1: Main

        static void Main( string[] args )
        {
            if (args.Length != 1) {
                PrintHelp();
                return;
            }

            BigEndianBinaryReader bebr = null;
            try {
                bebr = new BigEndianBinaryReader( new FileStream(args[0], FileMode.Open) );
            } catch (Exception ex) {
                Console.WriteLine("Error : {0}", ex.Message);
                return;
            }
            Header header = bebr.ReadBytes(Marshal.SizeOf(typeof(Header))).ToStruct<Header>();

            if (header.magic != 0x01000000004DA2DC) {
                Console.WriteLine("Not a valid TRP file.");
                return;
            }
            FileOffsetInfo[] fileOffsetInfoArray = new FileOffsetInfo[header.AllFileCount];
            for (int i = 0; i < header.AllFileCount; i++) {
                fileOffsetInfoArray[i] = bebr.ReadBytes(Marshal.SizeOf(typeof(FileOffsetInfo))).ToStruct<FileOffsetInfo>();
            }

            foreach (FileOffsetInfo foi in fileOffsetInfoArray) {
                bebr.BaseStream.Position = foi.Offset;
                FileStream fs = new FileStream(foi.fileName, FileMode.Create);
                byte [] towritefiledata = bebr.ReadBytes( (int) foi.FileSize );
                fs.Write(towritefiledata, 0, towritefiledata.Length);
                fs.Flush();
                fs.Close();
                Console.WriteLine(foi.fileName);
            }

            Console.WriteLine("Extract finished");
            bebr.Close();
            return;
        }
开发者ID:darkautism,项目名称:PS3TRPExtractor,代码行数:39,代码来源:Program.cs

示例2: TROPUSR

        public TROPUSR(string path_in)
        {
            this.path = path_in;
            BigEndianBinaryReader TROPUSRReader = null;

            if (path == null)
                throw new Exception("Path cannot be null!");

            if (!path.EndsWith(@"\"))
                path += @"\";

            if (!File.Exists(path + "TROPUSR.DAT"))
                throw new Exception("Cannot find TROPUSR.DAT.");

            try {
                TROPUSRReader = new BigEndianBinaryReader(new FileStream(path + "TROPUSR.DAT", FileMode.Open));
            } catch (IOException) {
                throw new Exception("Cannot Open TROPUSR.DAT.");
            }

            header = TROPUSRReader.ReadBytes(Marshal.SizeOf(typeof(Header))).ToStruct<Header>();
            if (header.Magic != 0x0000000100ad548f81)
                throw new Exception("Not a vaild TROPUSR.DAT.");

            typeRecordTable = new Dictionary<int, TypeRecord>();
            for (int i = 0; i < header.UnknowCount; i++) {
                TypeRecord TypeRecordTmp = TROPUSRReader.ReadBytes(Marshal.SizeOf(typeof(TypeRecord))).ToStruct<TypeRecord>();
                typeRecordTable.Add(TypeRecordTmp.ID, TypeRecordTmp);
            }

            do {
                // 1 unknow 2 account_id 3 trophy_id and hash(?) 4 trophy info
                //
                int type = TROPUSRReader.ReadInt32();
                int blocksize = TROPUSRReader.ReadInt32();
                int sequenceNumber = TROPUSRReader.ReadInt32(); // if have more than same type block, it will be used
                int unknow = TROPUSRReader.ReadInt32();
                byte[] blockdata = TROPUSRReader.ReadBytes(blocksize);
                switch (type) {
                    case 1: // unknow
                        break;
                    case 2:
                        account_id = Encoding.UTF8.GetString(blockdata, 16, 16);
                        break;
                    case 3:
                        trophy_id = Encoding.UTF8.GetString(blockdata, 0, 16).Trim('\0');
                        short u1 = BitConverter.ToInt16(blockdata, 16).ChangeEndian();
                        short u2 = BitConverter.ToInt16(blockdata, 18).ChangeEndian();
                        short u3 = BitConverter.ToInt16(blockdata, 20).ChangeEndian();
                        short u4 = BitConverter.ToInt16(blockdata, 22).ChangeEndian();
                        all_trophy_number = BitConverter.ToInt32(blockdata, 24).ChangeEndian();
                        int u5 = BitConverter.ToInt32(blockdata, 28).ChangeEndian();
                        AchievementRate[0] = BitConverter.ToUInt32(blockdata, 64);
                        AchievementRate[1] = BitConverter.ToUInt32(blockdata, 68);
                        AchievementRate[2] = BitConverter.ToUInt32(blockdata, 72);
                        AchievementRate[3] = BitConverter.ToUInt32(blockdata, 76);
                        break;
                    case 4:
                        trophyTypeTable.Add(blockdata.ToStruct<TrophyType>());
                        break;
                    case 5:
                        trophyListInfo = blockdata.ToStruct<TrophyListInfo>();
                        break;
                    case 6:
                        trophyTimeInfoTable.Add(blockdata.ToStruct<TrophyTimeInfo>());
                        break;
                    case 7:// unknow
                        unknowType7 = blockdata.ToStruct<UnknowType7>();
                        // Console.WriteLine("Unsupported block type. (Type{0})", type);
                        break;
                    case 8: // hash
                        unknowHash = blockdata.SubArray(0, 20);
                        break;
                    case 9: // 通常寫著白金獎盃的一些數字,不明
                        // Console.WriteLine("Unsupported block type. (Type{0})", type);
                        break;
                    case 10: // i think it just a padding
                        break;
                }

            } while (TROPUSRReader.BaseStream.Position < TROPUSRReader.BaseStream.Length);

            trophyListInfo.ListLastUpdateTime = DateTime.Now;
            TROPUSRReader.Close();
        }
开发者ID:darkautism,项目名称:TROPHYParser,代码行数:85,代码来源:TROPUSR.cs

示例3: ReadMBRs

 public override IEnumerable<MBRInfo> ReadMBRs(BigEndianBinaryReader reader)
 {
     reader.Close();
     return new MBRInfo[0];
 }
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:5,代码来源:NullShapeHandler.cs

示例4: TROPTRNS

        public TROPTRNS(string path_in)
        {
            this.path = path_in;
            BigEndianBinaryReader TROPTRNSReader = null;
            try {

                if (path == null)
                    throw new Exception("Path cannot be null!");

                if (!path.EndsWith(@"\"))
                    path += @"\";

                if (!File.Exists(path + "TROPTRNS.DAT"))
                    throw new Exception("Cannot find TROPTRNS.DAT.");

                try {
                    TROPTRNSReader = new BigEndianBinaryReader(new FileStream(path + "TROPTRNS.DAT", FileMode.Open));
                } catch (IOException) {
                    throw new Exception("Cannot Open TROPTRNS.DAT.");
                }

                header = TROPTRNSReader.ReadBytes(Marshal.SizeOf(typeof(Header))).ToStruct<Header>();
                if (header.Magic != 0x0000000100ad548f81) {
                    TROPTRNSReader.Close();
                    throw new Exception("Not a vaild TROPTRNS.DAT.");
                }

                typeRecordTable = new Dictionary<int, TypeRecord>();
                for (int i = 0; i < header.UnknowCount; i++) {
                    TypeRecord TypeRecordTmp = TROPTRNSReader.ReadBytes(Marshal.SizeOf(typeof(TypeRecord))).ToStruct<TypeRecord>();
                    typeRecordTable.Add(TypeRecordTmp.ID, TypeRecordTmp);
                }

                // Type 2
                TypeRecord account_id_Record = typeRecordTable[2];
                TROPTRNSReader.BaseStream.Position = account_id_Record.Offset + 32; // 空行
                account_id = Encoding.UTF8.GetString(TROPTRNSReader.ReadBytes(16));

                // Type 3
                TypeRecord trophy_id_Record = typeRecordTable[3];
                TROPTRNSReader.BaseStream.Position = trophy_id_Record.Offset + 16; // 空行
                trophy_id = Encoding.UTF8.GetString(TROPTRNSReader.ReadBytes(16)).Trim('\0');
                u1 = TROPTRNSReader.ReadInt32(); // always 00000090
                AllGetTrophysCount = TROPTRNSReader.ReadInt32();
                AllSyncPSNTrophyCount = TROPTRNSReader.ReadInt32();

                // Type 4
                TypeRecord TrophyInfoRecord = typeRecordTable[4];
                TROPTRNSReader.BaseStream.Position = TrophyInfoRecord.Offset; // 空行
                int type = TROPTRNSReader.ReadInt32();
                int blocksize = TROPTRNSReader.ReadInt32();
                int sequenceNumber = TROPTRNSReader.ReadInt32(); // if have more than same type block, it will be used
                int unknow = TROPTRNSReader.ReadInt32();
                byte[] blockdata = TROPTRNSReader.ReadBytes(blocksize);
                trophyInitTime = blockdata.ToStruct<TrophyInitTime>();

                for (int i = 0; i < (AllGetTrophysCount - 1); i++) {
                    TROPTRNSReader.BaseStream.Position += 16;
                    TrophyInfo ti = TROPTRNSReader.ReadBytes(blocksize).ToStruct<TrophyInfo>();
                    trophyInfoTable.Add(ti);
                }
            } finally {
                if (TROPTRNSReader != null) TROPTRNSReader.Close();
            }
        }
开发者ID:darkautism,项目名称:TROPHYParser,代码行数:65,代码来源:TROPTRNS.cs

示例5: ShapeReader

		/// <summary>
		/// Initializes a new instance of the Shapefile class with the given parameters.
		/// </summary>
		/// <param name="filename">The filename of the shape file to read (with .shp).</param>
		/// <param name="geometryFactory">The GeometryFactory to use when creating Geometry objects.</param>
		public ShapeReader(string filename, GeometryFactory geometryFactory)
		{           
			if (filename == null)
				throw new ArgumentNullException("filename");
			if (geometryFactory == null)
				throw new ArgumentNullException("geometryFactory");
			
            _filename = filename;
            _geometryFactory = geometryFactory;					

			// read header information. note, we open the file, read the header information and then
			// close the file. This means the file is not opened again until GetEnumerator() is requested.
			// For each call to GetEnumerator() a new BinaryReader is created.
			FileStream stream = new FileStream(filename, System.IO.FileMode.Open, FileAccess.Read, FileShare.Read);
			BigEndianBinaryReader shpBinaryReader = new BigEndianBinaryReader(stream);
			_mainHeader = new ShapefileHeader(shpBinaryReader);
			shpBinaryReader.Close();
		}
开发者ID:zhongshuiyuan,项目名称:mapwindowsix,代码行数:23,代码来源:ShapeReader.cs


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