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);
  • 相关阅读:
    windows常用命令行总结
    express安装
    MySQL去除外键关联关系
    c#实体转化
    C#之Clone
    mysql 将null转代为0(转)
    Mysql显示行号
    mysql存储过程游标加计划任务事件调度器
    mysql临时表
    Git学习笔记
  • 原文地址:https://www.cnblogs.com/demoC/p/5107663.html
Copyright © 2011-2022 走看看