zoukankan      html  css  js  c++  java
  • Path静态类

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.IO;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    
    namespace 文件IO
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private void butFile_Click(object sender, EventArgs e)
            {   
                //更改路径字符串的后缀名,不会改变实际路径
                string newPath = Path.ChangeExtension(@"D:\1.txt", "avi");
                //合并多个字符路径如果没有\自动加
                newPath = Path.Combine(@"12.txt", "12.txt");
                string path = @"G:\BaiduYunDownload\update.bin";
                //得到文件路径所在目录,如果本身就是目录路径则直接返回
                //只是操作字符串,不会去寻找文件
                newPath = Path.GetDirectoryName(path);
                //得到指定路径的文件名,如果不是文件路径,返回空串
                newPath = Path.GetExtension(path);
                //得到路径的文件名(文件名是带扩展名的)
                newPath = Path.GetFileName(path);
                //得到没有后缀名的文件名
                newPath = Path.GetFileNameWithoutExtension(path);
                //由文件在程序的相对路径得到文件的绝对物理路径
                newPath = Path.GetFullPath(path );
                //得到系统的临时目录,使用完由系统清除
                newPath = Path.GetTempPath();
                //产生一个随机的系统temp文件,返回文件名;
                newPath = Path.GetTempFileName();
    
            }
        }
    }
  • 相关阅读:
    【UVA–11997 K Smallest Sums 】
    【LA 3027 Corporative Network】
    【bzoj3173-最长上升子序列-一题两解】
    【Rain in ACStar HDU-3340】
    【Uva 11280 飞到弗雷德里顿】
    【Uva 10269 马里奥与公主的归途】
    【Uva 11604 编码都有歧义了】
    【RevolC FaeLoN Uva 10972】
    oracle解析xml(增加对9i版本的支持)
    acl操作记录
  • 原文地址:https://www.cnblogs.com/liuhao2050/p/3795243.html
Copyright © 2011-2022 走看看