• asp.net关于上传文件修改文件名的方法


    我这里主要用到了文件的复制方法

     string SavesUPLoadPath = ConfigurationManager.AppSettings["AWUploadLocation"] + CompanyName + "/";
                            string copySavesUPLoadPath = ConfigurationManager.AppSettings["AWUploadLocation"] + CompanyName + "/";
                            if (!Directory.Exists(SavesUPLoadPath))//判断上传文件夹是否存在,若不存在,则创建
                            {
                                Directory.CreateDirectory(SavesUPLoadPath);//创建文件夹
                            }

                         
                            SavesUPLoadPath = SavesUPLoadPath + FileUpload1.FileName;
                            FileUpload1.SaveAs(SavesUPLoadPath);
                            string NewSaveUPLoadPath = copySavesUPLoadPath + txtRefNO.Text + "-" + DateTime.Now.Year + "-" + DateTime.Now.Month + "-" + DateTime.Now.Day + "-" + DateTime.Now.Hour + "-" + DateTime.Now.Minute + ".pdf";
                            File.Copy(SavesUPLoadPath, NewSaveUPLoadPath);   ---------把文件赋给新的 //复制文件的作用
                            File.Delete(SavesUPLoadPath); --在删除原来的
                            Response.Write(NewSaveUPLoadPath);
                         
                            labeMess.Text = GetGlobalResourceObject("public", "UpLoadPdfsucceed").ToString();
                            btnSearch.Enabled = false;
                            btnUpLoadFile.Enabled = false;
                           

  • 相关阅读:
    【转载】搜索题目推荐
    HDU 4629 Burning 几何 + 扫描线
    HDU 4630 No Pain No Game 树状数组+离线查询
    SPOJ 416 Divisibility by 15 细节题
    【转载】树状数组题目
    SPOJ 274 Johnny and the Watermelon Plantation(TLE)
    SPOJ 227 Ordering the Soldiers 线段树 / 树状数组
    HDU 4620 Fruit Ninja Extreme 搜索
    Java序列化与反序列化
    Java IO包装流如何关闭?
  • 原文地址:https://www.cnblogs.com/yzenet/p/2651258.html
Copyright © 2020-2023  润新知