Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/256.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 将FileStream传递到IntPtr缓冲区_C#_File_Filestream_Intptr - Fatal编程技术网

C# 将FileStream传递到IntPtr缓冲区

C# 将FileStream传递到IntPtr缓冲区,c#,file,filestream,intptr,C#,File,Filestream,Intptr,我在尝试使用IntPtr直接从硬盘读取文件时遇到问题,目前我正在通过首先使用FileStream将其传递到字节数组,然后将字节数组复制到IntPtr来读取文件。但这种方法在处理大文件时会导致溢出。这就是为什么我现在尝试使用IntPtr直接从硬盘读取文件,但我还没有找到一种方法。IntPtr只是一个指针,所以它不能包含数据本身,必须在包含实际数据的地方有一个缓冲区 因此,使用一种缓冲区而不是另一种缓冲区并不能解决您的问题。如果您的文件不适合内存,那么您只需将其分成较小的部分进行处理

我在尝试使用IntPtr直接从硬盘读取文件时遇到问题,目前我正在通过首先使用FileStream将其传递到字节数组,然后将字节数组复制到IntPtr来读取文件。但这种方法在处理大文件时会导致溢出。这就是为什么我现在尝试使用IntPtr直接从硬盘读取文件,但我还没有找到一种方法。IntPtr只是一个指针,所以它不能包含数据本身,必须在包含实际数据的地方有一个缓冲区

因此,使用一种缓冲区而不是另一种缓冲区并不能解决您的问题。如果您的文件不适合内存,那么您只需将其分成较小的部分进行处理