public class ReadBigTxt
{
""
private string m_LogPath = "";
public ReadBigTxt()
{
}
public string GetFileTxt(string filename)
{
string str = "";
try
{
IntPtr vFileHandle = CreateFile(filename, GENERIC_READ | GENERIC_WRITE, FileShare.Read | FileShare.Write, IntPtr.Zero, FileMode.Open, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, IntPtr.Zero);
if (INVALID_HANDLE_VALUE != (int)vFileHandle)
{
IntPtr vMappingHandle = CreateFileMapping(
vFileHandle, IntPtr.Zero, PAGE_READWRITE, 0, 0, "temp");
if (vMappingHandle != IntPtr.Zero)
{
IntPtr vHead = MapViewOfFile(vMappingHandle,
FILE_MAP_COPY | FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, IntPtr.Zero);
if (vHead != IntPtr.Zero)
{
uint vSize = GetFileSize(vFileHandle, IntPtr.Zero);
byte[] nb = new byte[vSize];
Marshal.Copy(vHead, nb, 0, nb.Length);
str = System.Text.Encoding.GetEncoding("GB2312").GetString(nb);
nb = null;
UnmapViewOfFile(vHead);
}
CloseHandle(vMappingHandle);
}
CloseHandle(vFileHandle);
}
}
catch
{
return "";
}
return str.Replace("\r", "").Replace("\n", "");
}
}
{
""
private string m_LogPath = "";
public ReadBigTxt()
{
}
public string GetFileTxt(string filename)
{
string str = "";
try
{
IntPtr vFileHandle = CreateFile(filename, GENERIC_READ | GENERIC_WRITE, FileShare.Read | FileShare.Write, IntPtr.Zero, FileMode.Open, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, IntPtr.Zero);
if (INVALID_HANDLE_VALUE != (int)vFileHandle)
{
IntPtr vMappingHandle = CreateFileMapping(
vFileHandle, IntPtr.Zero, PAGE_READWRITE, 0, 0, "temp");
if (vMappingHandle != IntPtr.Zero)
{
IntPtr vHead = MapViewOfFile(vMappingHandle,
FILE_MAP_COPY | FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, IntPtr.Zero);
if (vHead != IntPtr.Zero)
{
uint vSize = GetFileSize(vFileHandle, IntPtr.Zero);
byte[] nb = new byte[vSize];
Marshal.Copy(vHead, nb, 0, nb.Length);
str = System.Text.Encoding.GetEncoding("GB2312").GetString(nb);
nb = null;
UnmapViewOfFile(vHead);
}
CloseHandle(vMappingHandle);
}
CloseHandle(vFileHandle);
}
}
catch
{
return "";
}
return str.Replace("\r", "").Replace("\n", "");
}
}