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);
  • 相关阅读:
    2016.10.09
    Httpie 进行web请求模拟
    Python-集合
    python-字典
    MySQL权限系统
    MySQL8.0安装以及介绍(二进制)
    数据库对象中英文介绍
    Python-字符串
    GIT安装部署
    Cobbler安装部署
  • 原文地址:https://www.cnblogs.com/zhangwei595806165/p/3365366.html
Copyright © 2011-2022 走看看