zoukankan      html  css  js  c++  java
  • 文件操作类Path

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.IO;

    namespace 文件操作Path类
    {
        class Program
        {
            static void Main(string[] args)
            {
                string p = @"c:\abc\ab\a\b.txt";
                string fn = Path.GetFileName(p);
                Console.WriteLine(fn);
                //这里并没有修改了实际的文件名,知识把字符串p,改成了
                //"c:\abc\ab\a\b.jpg"
                string pResult = Path.ChangeExtension(p, ".jpg");
                Console.WriteLine(pResult);

                string dir = Path.GetDirectoryName(p);
                Console.WriteLine(dir);

                string s1 = @"c:\a\b";
                string s2 = "x.jpg";
                //string r = s1 + s2;
                string r = Path.Combine(s1, s2);
                Console.WriteLine(r);

                string ext = Path.GetExtension(p);
                Console.WriteLine(ext);

                string fnWithoutExt = Path.GetFileNameWithoutExtension(p);
                Console.WriteLine(fnWithoutExt);
                //获得指定路径对应的绝对路径(完整的路径。 )
                string fullPath = Path.GetFullPath("..");
                Console.WriteLine(fullPath);
                //
                Console.WriteLine("临时目录:{0}", Path.GetTempPath());
                Console.WriteLine();
                Console.WriteLine("临时文件名 :{0}", Path.GetTempFileName());
                
                Console.ReadKey();
            }
        }
    }

  • 相关阅读:
    arm-linux-3.4.2移植for2440
    编译内核是出现:arch/arm/mm/tlb-v4wbi.S:64:error: too many positional arguments
    poj3050 Hopscotch
    poj3187 Backward Digit Sums
    poj2718 Smallest Difference
    hihocoder offer收割编程练习赛10 C 区间价值
    poj1862 Stripies
    poj3262 Protecting the Flowers
    poj2229 Sumsets
    poj2385 Apple Catching
  • 原文地址:https://www.cnblogs.com/zpc870921/p/2640585.html
Copyright © 2011-2022 走看看