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


C# FileStream.ReadUInt16方法代码示例

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


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

示例1: Execute

        public static int Execute( List<string> args )
        {
            if ( args.Count == 0 ) {
                Console.WriteLine( "This is intended to help extracting skit audio from the Xbox 360 game files." );
                Console.WriteLine( "Do the following in order:" );
                Console.WriteLine( "-- unpack chat.svo (FPS4 archive, with HyoutaTools -> ToVfps4e)" );
                Console.WriteLine( "-- decompress individual skit with xbdecompress" );
                Console.WriteLine( "-- unpack skit (FPS4 archive, with HyoutaTools -> ToVfps4e)" );
                Console.WriteLine( "-- cut SE3 header from audio file to get a nub archive" );
                Console.WriteLine( "   (file 0004, seems to be 0x800 bytes for skits but can be bigger, first four bytes of new file should be 0x00020100)" );
                Console.WriteLine( "-- extract nub archive with NUBExt r12beta" );
                Console.WriteLine( "-- this gives you an \"xma\" file that isn't actually an xma, run this tool on it" );
                Console.WriteLine( "-- resulting file is a valid enough xma file that can be converted to WAV with \"toWav\"" );
                return -1;
            }

            string filename = args[0];
            using ( var source = new FileStream( filename, FileMode.Open ) ) {
                using ( var dest = new FileStream( filename + "-real.xma", FileMode.Create ) ) {
                    source.Position = 0x100;
                    int dataLength = (int)( source.Length - source.Position );

                    dest.WriteAscii( "RIFF" );
                    dest.WriteUInt32( (uint)dataLength + 0x34 );
                    dest.WriteAscii( "WAVE" );
                    dest.WriteAscii( "fmt " );

                    dest.WriteUInt32( 0x20 );

                    source.Position = 0xBC;
                    dest.WriteUInt16( source.ReadUInt16().SwapEndian() );
                    dest.WriteUInt16( source.ReadUInt16().SwapEndian() );
                    dest.WriteUInt16( source.ReadUInt16().SwapEndian() );
                    dest.WriteUInt16( source.ReadUInt16().SwapEndian() );
                    dest.WriteUInt16( source.ReadUInt16().SwapEndian() );
                    dest.WriteByte( (byte)source.ReadByte() );
                    dest.WriteByte( (byte)source.ReadByte() );
                    dest.WriteUInt32( source.ReadUInt32().SwapEndian() );
                    dest.WriteUInt32( source.ReadUInt32().SwapEndian() );
                    dest.WriteUInt32( source.ReadUInt32().SwapEndian() );
                    dest.WriteUInt32( source.ReadUInt32().SwapEndian() );
                    dest.WriteByte( (byte)source.ReadByte() );
                    dest.WriteByte( (byte)source.ReadByte() );
                    dest.WriteUInt16( source.ReadUInt16().SwapEndian() );

                    dest.WriteAscii( "data" );
                    dest.WriteUInt32( (uint)dataLength );

                    source.Position = 0x100;
                    Util.CopyStream( source, dest, dataLength );
                }
            }

            return 0;
        }
开发者ID:AdmiralCurtiss,项目名称:HyoutaTools,代码行数:55,代码来源:FixHeader.cs

示例2: LoadFile

        private bool LoadFile( string headerFilename, string contentFilename = null )
        {
            try {
                infile = new FileStream( headerFilename, FileMode.Open );
                if ( contentFilename != null ) {
                    contentFile = new FileStream( contentFilename, FileMode.Open );
                } else {
                    contentFile = infile;
                }
            } catch ( Exception ) {
                Console.WriteLine( "ERROR: can't open " + headerFilename );
                return false;
            }

            infile.Seek( 0x00, SeekOrigin.Begin );
            string magic = infile.ReadAscii( 4 );
            if ( magic != "FPS4" ) {
                Console.WriteLine( "Not an FPS4 file!" );
                return false;
            }

            Endian = Util.Endianness.BigEndian;
            FileCount = infile.ReadUInt32().FromEndian( Endian );
            HeaderSize = infile.ReadUInt32().FromEndian( Endian );

            // if header seems huge then we probably have assumed the wrong endianness
            if ( HeaderSize > 0xFFFF ) {
                Endian = Util.Endianness.LittleEndian;
                FileCount = FileCount.ToEndian( Util.Endianness.BigEndian ).FromEndian( Endian );
                HeaderSize = HeaderSize.ToEndian( Util.Endianness.BigEndian ).FromEndian( Endian );
            }

            FirstFileStart = infile.ReadUInt32().FromEndian( Endian );
            EntrySize = infile.ReadUInt16().FromEndian( Endian );
            ContentBitmask = infile.ReadUInt16().FromEndian( Endian );
            Unknown2 = infile.ReadUInt32().FromEndian( Endian );
            ArchiveNameLocation = infile.ReadUInt32().FromEndian( Endian );
            infile.Position = ArchiveNameLocation;
            if ( ArchiveNameLocation > 0 ) {
                ArchiveName = infile.ReadShiftJisNullterm();
            }

            Alignment = FirstFileStart;

            Console.WriteLine( "Content Bitmask: 0x" + ContentBitmask.ToString( "X4" ) );

            return true;
        }
开发者ID:AdmiralCurtiss,项目名称:HyoutaTools,代码行数:48,代码来源:FPS4.cs


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