• webfrom后台


    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    namespace LTT_shenpi
    {
    public partial class WebForm1 : System.Web.UI.Page
    {
    protected void Page_Load(object sender, EventArgs e)
    {
    if (!IsPostBack) { }
    }
    public string GetPictureData(string imagepath, string imgname)
    {
    //根据图片文件的路径使用文件流打开,并保存为byte[]

    DateTime dt = DateTime.Now;

    string paths = Server.MapPath("/Image/").ToString();
    if (System.IO.Directory.Exists(paths + dt.Year)) //己经存在 年文件夹
    {
    if (System.IO.Directory.Exists(paths + dt.Year + "/" + dt.Month)) //己经存在 月文件夹
    {

    }
    else
    {
    System.IO.Directory.CreateDirectory(paths + dt.Year + "/" + dt.Month);
    }
    }
    else
    {
    System.IO.Directory.CreateDirectory(paths + dt.Year);
    if (System.IO.Directory.Exists(paths + dt.Year + "/" + dt.Month)) //己经存在 月文件夹
    {

    }
    else
    {
    System.IO.Directory.CreateDirectory(paths + dt.Year + "/" + dt.Month);
    }
    }
    // FileStream fs = new FileStream(imagepath, FileMode.Open);

    byte[] accessory = Convert.FromBase64String(imagepath);
    //byte[] byData = new byte[fs.Length];

    System.IO.Stream s = new System.IO.MemoryStream(accessory);
    System.Drawing.Image image = System.Drawing.Image.FromStream(s);
    string pathstr = Server.MapPath("/Image/" + dt.Year + "/" + dt.Month + "/").ToString() + dt.ToString("yyyyMMddhhmmssfff") + imgname + ".jpg";
    // string pathstr = Server.MapPath("/Image/"+ dt.Year + "/" + dt.Month + "/") + dt.ToString("yyyyMMddhhmmssfff") + imgname + ".jpg";
    // string pathstr = "d:/Image/" + dt.Year + "/" + dt.Month + "/" + dt.ToString("yyyyMMddhhmmssfff") + imgname + ".jpg";
    string sqlpath = "/Image/" + dt.Year + "/" + dt.Month + "/" + dt.ToString("yyyyMMddhhmmssfff") + imgname + ".jpg";
    image.Save(pathstr);
    return sqlpath;
    }
    }
    }

  • 相关阅读:
    证明欧几里得算法的正确性
    基础练习 十六进制转换八进制
    算法训练 关联矩阵
    寻找数组中最大值
    Torry的困惑(基本型)
    最小乘积(基本型)
    矩阵乘法
    SaltStack Char02 组件
    SaltStack Char01
    Python 学习手册, char 14
  • 原文地址:https://www.cnblogs.com/1971855407qq/p/8600237.html
Copyright © 2020-2023  润新知