Esempio n. 1
0
        public string SaveImageFile(IFormFileCollection filelist)
        {
            try
            {
                IFormFile file      = filelist[0];                                            //默认值上传一张图片;获取第一个文件
                string    filename  = FileManage.GenerateFileName(file.FileName);             //上传文件名(唯一)
                string    recv_Path = Path.Combine(FileManage.GetSaveFolderPath(), filename); //保存路径+文件名

                try
                {
                    using (FileStream fs = new FileStream(recv_Path, FileMode.Create, FileAccess.Write))
                    {
                        file.CopyTo(fs);
                    }

                    return(recv_Path);
                }
                catch (Exception)
                {
                    throw new MyException("上传文件写入异常! 写入路径:" + recv_Path);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// 解析路径下的红外图片,获取相关信息
        /// </summary>
        /// <param name="file_path">文件路径</param>
        /// <param name="pic_info">识别区域信息</param>
        /// <returns></returns>
        public void OpenPicAsync(string file_path, List <Rect_param> pic_param_list)
        {
            try
            {
                using (ThermalImageFile th = new ThermalImageFile(file_path))   //打开热成像图片文件
                {
                    //拼接结果文件路径
                    string savepath = System.IO.Path.Combine(FileManage.GetResultFolderPath(), FileManage.GenerateFileName(th.Title));

                    //处理图片,获取结果信息
                    using (Bitmap saveimage = DrawRectangleInPicture(th, pic_param_list, Color.FromArgb(117, 251, 253), 2, DashStyle.Solid))
                    {
                        saveimage.Save(savepath);         //保存结果图片
                        //this.result_file_name = System.IO.Path.GetFileName(savepath); // 保存结果文件路径
                        this.result_file_name = savepath; // 保存结果文件路径
                    }
                    this.picBaseInfo = DetailInfo(th);
                }
            }
            catch (Exception ex)
            {
                //if (System.IO.File.Exists(file_path)) //删除非红外图片
                //    System.IO.File.Delete(file_path);
                throw new MyException("解析对象不是红外图片!" + ex.ToString());
            }
        }
Esempio n. 3
0
        public static string[] SaveFile(IFormFileCollection filelist)
        {
            string[] filenames = new string[filelist.Count];
            for (int i = 0; i < filelist.Count; i++)
            {
                try
                {
                    IFormFile file = filelist[i];
                    //string filename = FileManage.GenerateFileName(file.FileName); //上传文件名(唯一)
                    string filename  = file.FileName;                                          //上传文件名(唯一)
                    string recv_Path = Path.Combine(FileManage.GetSaveFolderPath(), filename); //保存路径+文件名

                    using (FileStream fs = new FileStream(recv_Path, FileMode.Create, FileAccess.Write))
                    {
                        file.CopyTo(fs);
                    }
                    filenames[i] = recv_Path;
                }
                catch (Exception)
                {
                    filenames[i] = string.Empty;
                    throw new MyException("上传文件写入异常! ");
                }
            }
            return(filenames);
        }