zoukankan      html  css  js  c++  java
  • 向项目的文件夹中写入数据流

     public void GetChargStationFileCount(HttpContext context)
            {
                var chargstationfilebll = new ChargStationFileBll();
                var cPictureMessage = new Message<Picture>();
                var fileid = context.Request.Params["id"];
                string ret = null;
                if (string.IsNullOrEmpty(fileid))
                {
                    cPictureMessage.Total = 0;
                    return;
                }
                var chargstationfile = new ChargStationFile
                    {
                        ZhanBh = int.Parse(fileid)
                    };
                try
                {
                    var dt = chargstationfilebll.FindBy(chargstationfile);
                    var list = ConvertHelper<Picture>.ConvertToList(dt);
                    foreach (var li in list)
                    {
                        var bytes = li.FileContext;
                        if (bytes == null) continue;
                        var stream = new MemoryStream(bytes);
                        var img = Image.FromStream(stream);
                        string path = AppDomain.CurrentDomain.BaseDirectory;//获取文件的相对路径
                        string filePath = path + @"ScriptspictureChargStationSaveChargeStationFile";
                        img.Save(filePath + li.Id + "." + li.FileMime);
                        var w = img.Width;
                        var h = img.Height;
                        li.Width = w;
                        li.Height = h;
                        li.FileContext = null;
                    }
    
                    cPictureMessage.Rows = list;
                    ret = Jss.Serialize(cPictureMessage);
    
                }
                catch (Exception e)
                {
                    Log.Error(e);
                    throw;
                }
                context.Response.Write(ret);
  • 相关阅读:
    cnpm镜像安装
    wxParse解析html
    C++回调函数
    QT源码分析:QTcpServer
    QT实现支持加密的Sqlite数据库引擎
    VS2013+OpenCV3.4.2编译
    Android Tcp操作
    使用Delphi开发linux应用
    QT5.10+MinGW+OpenCV3.4.2编译
    C++ ActiveX开发的问题讨论
  • 原文地址:https://www.cnblogs.com/zhangwei595806165/p/3365366.html
Copyright © 2011-2022 走看看