zoukankan      html  css  js  c++  java
  • 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);
  • 相关阅读:
    20188477 编程作业
    原型设计
    案例分析
    编程作业
    阅读任务
    准备工作
    原型设计作业
    案例分析作业
    编程作业
    阅读任务
  • 原文地址:https://www.cnblogs.com/demoC/p/5107663.html
Copyright © 2011-2022 走看看