首页 > 如何将读取到的Stream保存为动态的gif

如何将读取到的Stream保存为动态的gif

hi all:我有个需求,就是写个接口,把传过来的gif文件流Stream保存在服务器上,并且也是动态的gif文件。我尝试了网上的说法,似乎不行,请高手指点。


    /// <summary>
    /// Copies the contents of input to output. Doesn't close either stream.
    /// </summary>
    public static void CopyStream(Stream input, Stream output)
    {
        byte[] buffer = new byte[8 * 1024];
        int len;
        while ((len = input.Read(buffer, 0, buffer.Length)) > 0)
        {
            output.Write(buffer, 0, len);
        }
    }

调用 using (Stream fileGif = File.OpenWrite(file)) { CopyStream(inputStream, fileGif); }

刚试了,可以。

【热门文章】
【热门文章】