【问题标题】:How to save a Text/document file to specific folder using MemoryStream in asp.net using c#?如何使用 c# 在 asp.net 中使用 MemoryStream 将文本/文档文件保存到特定文件夹?
【发布时间】:2013-03-20 15:08:25
【问题描述】:

我有一个来自 Sharepoint 文档库的文件路径。 FileStrem 包含来自服务器的文件流字节。现在我想Save file 从这些字节使用 MemoryStream 到使用 C# 在 asp.net 中的特定文件夹。

public byte[] FileStream { get; set; }

下面的代码我用来从共享点保存图像文件。它有效!

MemoryStream mStream = new MemoryStream(analystPhotoObj.FileStream);
Bitmap bitmap = new Bitmap(mStream);
bitmap.Save(path + @"\MemberPhoto\" + analystPhotoObj.DocumentID + "." + analystPhotoObj.FileType);

现在我想要保存 text/document 文件的方法相同。唯一的问题是 FILE TYPE 正在从 *BITMA*P 更改为 文本/文档文件

帮助表示赞赏! 谢谢!

【问题讨论】:

    标签: c# asp.net sharepoint-2010 save memorystream


    【解决方案1】:

    尝试使用 bitmap.Save 的第二个参数:

    保存(流,System.Drawing.Imaging.ImageFormat.Bmp)

    【讨论】:

    • 我要保存文本文件而不是图像文件!
    • 你说文件类型从Bitmap改成Text/Document,如果你说你上传的是txt文件,那不好吗?
    猜你喜欢
    • 2022-06-29
    • 1970-01-01
    • 2019-05-15
    • 2021-06-13
    • 1970-01-01
    • 1970-01-01
    • 2013-04-28
    • 2012-06-18
    • 1970-01-01
    相关资源
    最近更新 更多