1

我正在尝试将整数数组创建到内存映射文件中并在 C++ 中读取该文件,但我不会在这里询问 c++ 部分。MakeMem() 有 {"缓冲区中没有足够的可用空间。"}

Private Sub MakeMem()
Dim integer2 = New Integer(31) {}
For j As Integer = 0 To integer2.Length - 1
        integer2(j) = 35 - j
Next
MemoryMappedFile.CreateOrOpen("0MemF", integer2.Length + 1).CreateViewAccessor(0, integer2.Length).WriteArray(Of Integer)(0, integer2, 0, integer2.Length)
End Sub

首先在VB中测试,从内存中读取数组

Private Sub ReadMem()
    Try
        Dim integer3 = New Integer(31) {}

        MemoryMappedFile.OpenExisting("0MemF").CreateViewAccessor(0, integer3.Length + 1).ReadArray(Of Integer)(0, integer3, 0, integer3.Length)

                TextBox1.Text = ""
                For i As Integer = 0 To integer3.Length - 1
                    TextBox1.AppendText(CStr(integer3(i)) + " ")
                Next


            End Using
        End Using
    Catch noFile As FileNotFoundException

        TextBox1.Text = "Mem-map not found"
    Catch Ex As Exception

    End Try
End Sub
4

0 回答 0