如何加载一个文件到内存流 [英] how to load a file into memory stream

查看:100
本文介绍了如何加载一个文件到内存流的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个文件名(包括它的路径)的字符串。现在我想加载此.csv文件到内存流。有什么建议吗?

I have a filename(including it's path) in a string. Now i want to load this .csv file into memory stream. Any suggestions please?

例如:昏暗的文件名作为字符串=C:\用户\桌面\ abc.csv

ex: Dim filename as string="C:\Users\Desktop\abc.csv"

推荐答案

您并不需要加载一个文件到MemoryStream。

You don't need to load a file into a MemoryStream.

您可以简单地调用 File.OpenRead 获得的FileStream 包含文件。

You can simply call File.OpenRead to get a FileStream containing the file.

如果你真的想要的文件是在一个MemoryStream,你可以叫 CopyTo从到FileStream复制到一个MemoryStream。

If you really want the file to be in a MemoryStream, you can call CopyTo to copy the FileStream to a MemoryStream.

这篇关于如何加载一个文件到内存流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆