Correct, FileStream
would be the appropriate stream class to use for reading buffered file data from disk.
Where do you need to write the data to?
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi,
I need to pass some files on disk as stream to a 3rd party SDK for some processing and don't know if I should use FileStream or MemoryStream?
When reading, there are files on disk that I load and pass to the SDK to extract some data from:
Using memStream As New MemoryStream(File.ReadAllBytes("c:\blah.ext"), FileMode.Open, FileAccess.Read)
This file can be big, so I guess should be using FileStream:
Using fileStream As New FileStream("c:\blah.ext", FileMode.Open, FileAccess.Read)
Am I right?
If using FileStream, the file is just opened as read-only in-place?
2nd scenario is writing, what's the advise on it?
Correct, FileStream
would be the appropriate stream class to use for reading buffered file data from disk.
Where do you need to write the data to?
Hi @S-Soft ,
Based on what kind of input is required by the SDK.
You can choose a different FileAccess Enum for FileStream (String, FileMode, FileAccess).
Read
Read access to the file. Data can be read from the file. Combine with Write for read/write access.
ReadWrite
Read and write access to the file. Data can be written to and read from the file.
Write
Write access to the file. Data can be written to the file. Combine with Read for read/write access.
Best Regards.
Jiachen Li
----------
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.