• ¡Welcome to Square Theme!
  • This news are in header template.
  • Please ignore this message.
مهمان عزیز خوش‌آمدید. ورود عضــویت


امتیاز موضوع:
  • 27 رای - 2.63 میانگین
  • 1
  • 2
  • 3
  • 4
  • 5
Title: Run in memory
حالت موضوعی
#1
کد:
' open a file stream for reading, and load into a memory stream
  Public Shared Function StreamToMemory(ByVal path As String) As IO.MemoryStream
    Dim input As IO.FileStream
    Dim output As IO.MemoryStream
    input = New IO.FileStream(path, IO.FileMode.Open, IO.FileAccess.Read, IO.FileShare.Read)
    output = StreamToMemory(input)
    input.Close()
    Return output
  End Function
  ' transfer contents of input stream to memory stream
  Public Shared Function StreamToMemory(ByVal input As IO.Stream) As IO.MemoryStream
    Dim buffer(1023) As Byte
    Dim count As Integer = 1024
    Dim output As IO.MemoryStream
    ' build a new stream
    If input.CanSeek Then
      output = New IO.MemoryStream(input.Length)
    Else
      output = New IO.MemoryStream
    End If
    ' iterate stream and transfer to memory stream
    Do
      count = input.Read(buffer, 0, count)
      If count = 0 Then Exit Do
      output.Write(buffer, 0, count)
    Loop
    ' rewind stream
    output.Position = 0
    ' pass back
    Return output
  End Function
گروه دور همی پارسی کدرز
https://t.me/joinchat/GxVRww3ykLynHFsdCvb7eg
 
پاسخ
  


پرش به انجمن:


Browsing: 1 مهمان