本文整理汇总了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;
}
示例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;