當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。