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


C# FileStream.ReadValueU16方法代码示例

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


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

示例1: OpenMEPackage

        public static IMEPackage OpenMEPackage(string pathToFile, WPFBase wpfWindow = null, WinFormsBase winForm = null)
        {
            IMEPackage package = null;
            if (!openPackages.ContainsKey(pathToFile))
            {
                ushort version;
                ushort licenseVersion;
                using (FileStream fs = new FileStream(pathToFile, FileMode.Open, FileAccess.Read))
                {
                    fs.Seek(4, SeekOrigin.Begin);
                    version = fs.ReadValueU16();
                    licenseVersion = fs.ReadValueU16();
                }

                if (version == 684 && licenseVersion == 194)
                {
                    package = ME3ConstructorDelegate(pathToFile);
                }
                else if (version == 512 && licenseVersion == 130)
                {
                    package = ME2ConstructorDelegate(pathToFile);
                }
                else if (version == 491 && licenseVersion == 1008)
                {
                    package = ME1ConstructorDelegate(pathToFile);
                }
                else
                {
                    throw new FormatException("Not an ME1, ME2, or ME3 package file.");
                }
                package.noLongerUsed += Package_noLongerUsed;
                openPackages.Add(pathToFile, package);
            }
            else
            {
                package = openPackages[pathToFile];
            }

            if (wpfWindow != null)
            {
                package.RegisterTool(new GenericWindow(wpfWindow, Path.GetFileName(pathToFile)));
                addToPackagesInTools(package);
            }
            else if (winForm != null)
            {
                package.RegisterTool(new GenericWindow(winForm, Path.GetFileName(pathToFile)));
                addToPackagesInTools(package);
            }
            else
            {
                package.RegisterUse();
            }
            return package;
        }
开发者ID:ME3Explorer,项目名称:ME3Explorer,代码行数:54,代码来源:MEPackageHandler.cs

示例2: Patch


//.........这里部分代码省略.........
                    {
                        while (Convert.ToBoolean(patch_blocks--))
                        {
                            if (pBar.InvokeRequired == true)
                            {
                                SetValue PSetValue = new SetValue(DoSetValue);
                                SetText LSetText = new SetText(DoSetText);
                                pBar.Invoke(PSetValue, new Object[] { pBar, Convert.ToInt32(j++) });
                                var per = Convert.ToDouble(j-1)/Convert.ToDouble(blocks);
                                lab.Invoke(LSetText, new Object[] { lab, Convert.ToString(Math.Ceiling(per*100)) + "%" });
                                Application.DoEvents();
                            }
                            Byte blocktype = 0;
                            UInt32 blocksize = 0;
                            blocktype = Convert.ToByte(Patchs.ReadByte()); read = 1;
                            if (blocktype==null)
                            {
                                return result.PATCH_CORRUPT;
                            }
                            switch (blocktype)
                            {
                                case 1:
                                case 2:
                                case 3:
                                    if (blocktype == 1)
                                    {
                                        Byte x;
                                        x = Convert.ToByte(Patchs.ReadByte()); read = 1;
                                        blocksize = Convert.ToUInt32(Convert.ToBoolean(x) ? x : 0);
                                    }
                                    else if (blocktype == 2)
                                    {
                                        UInt16 x;
                                        x = Patchs.ReadValueU16(); read = 2;
                                        blocksize = Convert.ToUInt32(Convert.ToBoolean(x) ? x : 0);
                                    }
                                    else
                                    {
                                        UInt32 x;
                                        x = Patchs.ReadValueU32(); read = 4;
                                        blocksize = Convert.ToUInt32(Convert.ToBoolean(x) ? x : 0);
                                    }
                                    temp = Patchs.ReadValueU32(); read = 4;
                                    if (!Convert.ToBoolean(blocksize) || temp == null || read != 4)
                                        return result.PATCH_CORRUPT;
                                    Sources.Seek(temp, SeekOrigin.Begin);
                                    //SetFilePointer(hSource, temp, 0, EMoveMethod.Begin);

                                    do
                                    {
                                        Sources.Read(block, 0, Convert.ToInt32(Math.Min(BLOCKSIZE, blocksize))); read = Math.Min(BLOCKSIZE, blocksize);
                                        if (block == null)
                                        {
                                            return result.PATCH_ERROR;
                                        }
                                        //IAsyncResult writeResult = Dests.BeginWrite(block,0,Convert.ToInt32(read),writeCallBack,"Write Target File");
                                        //Dests.EndWrite(writeResult);
                                        Dests.Write(block, 0, Convert.ToInt32(read));
                                        temp = read;
                                        //WriteFile(hDest, block, read, &temp, NULL);
                                        if (temp != Math.Min(BLOCKSIZE, blocksize))
                                            return result.PATCH_ERROR;
                                        blocksize -= temp;
                                    } while (Convert.ToBoolean(temp));

                                    break;
开发者ID:Windriderking,项目名称:ME3Patch,代码行数:67,代码来源:DoPatch.cs


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