流文件名或将流转换为DataTable
我正在从接口获取 System.IO.Stream 对象。
我想获取连接流的文件名的路径。由于流将发送到 Excel 文件或者我可以读取流并将其转换为 dataTable 吗?
I am getting System.IO.Stream object from an interface.
I want to get the path of file name from which stream is connect . As the stream will be to an excel file Or can I just read the stream and convert it into dataTable ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您无法获取所有流的文件名 - 它必须是 FileStream :
并且不,您不能将任何流转换为 DataTable。这取决于流中的内容。
You can not get the filename for all streams - it has to be a FileStream :
And No, you cannot convert just any stream to a DataTable. It depends on what is inside the stream.
如果这是一个内存流并且不涉及文件呢?
Stream
没有源信息,因此您无法获取此数据(即文件名)。至于将
Stream
转换为DataTable
- 您可以使用ReadXml
方法将 XML 加载到DataTable
并使用构造函数重载需要一个StreamingContext
,但这些不会简单地需要一个 Excel 文件。And if this is a memory stream and there is no file involved?
A
Stream
doesn't have source information, so you can't get this data (i.e. filename).As for converting a
Stream
to aDataTable
- you can load XML to aDataTable
using theReadXml
method and using the constructor overload that takes aStreamingContext
, but these wouldn't simply take an excel file.