Data Sender

PS C:\> $rawdata.GetType()
IsPublic IsSerial Name         BaseType
-------- -------- ----         --------
True     True     Byte[]       System.Array

PS C:\> $size = 1024
PS C:\> $data = $rawdata[0..($size - 1)]
PS C:\> $data.GetType()
IsPublic IsSerial Name         BaseType
-------- -------- ----         --------
True     True     Object[]     System.Array

PS C:\> $name = "Local\somenameobj"
PS C:\> $mmf = [System.IO.MemoryMappedFiles.MemoryMappedFile]::CreateNew($name, $size)
PS C:\> $mmfstream = $mmf.CreateViewStream()
PS C:\> $mmfstream.Write($data, 0, $size)
PS C:\> $mmfstream.Dispose()
PS C:\> 


Data Receiver

PS C:\> $data = New-Object Byte[] 1024
PS C:\> $data.GetType()
IsPublic IsSerial Name         BaseType
-------- -------- ----         --------
True     True     Byte[]       System.Array

PS C:\> $name = "Local\somenameobj"
PS C:\> $size = 1024
PS C:\> $mmf = [System.IO.MemoryMappedFiles.MemoryMappedFile]::OpenExisting($name)
PS C:\> $mmfstream = $mmf.CreateViewStream()
PS C:\> $mmfstream.Read($data, 0, $size)
1024
PS C:\> $mmfstream.Dispose()
PS C:\> 


Remark

.NET 4.0 이상 지원


References


신고

티스토리 툴바