• Path类使用


                //string imgname = Path.GetFileName(imgpic);
                //返回的是文件名与后缀名       3.png
                //string imgname = Path.GetDirectoryName(imgpic);
                //返回的是目录地址   ..CustomerPhoto2015815
                //string imgname = Path.GetExtension(imgpic);
                //返回的是后缀名     .png
                //string imgname = Path.GetFileNameWithoutExtension(imgpic);
                //返回的是文件名     3
                //string imgname = Path.GetFullPath(imgpic);
                //返回的是当前文件的绝对路径     C:Program Files (x86)CustomerPhoto20158153.png
                string imgname = Path.ChangeExtension(imgpic,".jpg");
                //替换原 后缀名
                string imgname = imgpic.Replace(
                    Path.GetFileNameWithoutExtension(imgpic), 
                    Path.GetFileNameWithoutExtension(imgpic) + "-1");
                //单独修改文件名的方法
                string filePath1 = context.Request.MapPath(imgpic);//获取大图图片的物理路径
                string filePath2 = filePath1.Replace(Path.GetFileNameWithoutExtension(filePath1),
                    Path.GetFileNameWithoutExtension(filePath1) + "-1");
                File.Copy(filePath1, filePath2);
  • 相关阅读:
    vue项目架构
    vue.js 视频播放
    Intellij使用"easyexplore"
    ScrollView嵌套GridView不显示顶部
    Android开发日志统一管理
    Android带弹性的View
    Mysql数据库乱码
    为Activity生成桌面快捷方式
    二维码扫描ZXing简化
    减少XML文件数
  • 原文地址:https://www.cnblogs.com/demoC/p/5107663.html
Copyright © 2020-2023  润新知