我正在使用Visual Studio 2013,我是C#的新手,并复制了这段代码以读取二进制文件的特定部分,但我无法修复它:
using System;
using System.IO;
using System.Runtime.InteropServices;
using Microsoft.Win32.SafeHandles;
namespace BinaryFileApplication
{
class Program
{
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
private static extern IntPtr CreateFile(string lpFileName, uint dwDesiredAccess,
uint dwShareMode, IntPtr lpSecurityAttributes, uint dwCreationDisposition,
uint dwFlagsAndAttributes, IntPtr hTemplateFile);
[DllImport("kernel32.dll", SetLastError = true)]
static extern bool ReadFile(IntPtr hFile, [Out] byte[] lpBuffer,
uint nNumberOfBytesToRead, out uint lpNumberOfBytesRead, IntPtr lpOverlapped);
static void Main(string[] args)
{
FileStream hFile = new FileStream("test.rex", FileMode.Open);
uint num = 24;
int timeFind = 0;
Array bytes;
ReadFile(hFile, (void*)(bytes), 24, &num, null);
timeFind = bytesToLong((byte*)(bytes), 0, 8);
Console.WriteLine("Time:", (int)timeFind);
return;
}
}
}
我该怎么做才能解决错误?