C# 文件路径 Path类 测试

 C#  文件路径  Path类 测试

腾出点时间对Path类做一个系统的测试

      


    private void PathTest()
        {
            //------------必须的空间-------using System.Diagnostics;     using System.IO;
            string path = @"C:\Users\cks\Desktop\zzg\ERPWork1125\User.lua";
            Debug.Print(Path.ChangeExtension(path, "txt"));                     // 输出:-----C:\Users\cks\Desktop\zzg\ERPWork1125\User.txt
            string path1 = @"C:\Users\cks\Desktop\zzg";
            string path2 = @"gg/e.txt";
            Debug.Print(Path.Combine(path1, path2));                            //输出:-----C:\Users\cks\Desktop\zzg\gg/e.txt
            Debug.Print(Path.GetDirectoryName(path));                           //输出:-----C:\Users\cks\Desktop\zzg\ERPWork1125
            Debug.Print(Path.GetExtension(path));                               //输出:-----.lua
            Debug.Print(Path.GetFileName(path));                                //输出:-----User.lua
            Debug.Print(Path.GetFileNameWithoutExtension(path));                //输出:-----User
            Debug.Print(Path.GetFullPath(path));                                // 输出:-----C:\Users\cks\Desktop\zzg\ERPWork1125\User.lua
            Debug.Print(String.Join("/x/"Path.GetInvalidFileNameChars()));    //输出:-----"/x/</x/>/x/|/x/
            Debug.Print(String.Join("/a/"Path.GetInvalidPathChars()));        //输出:----- " /a/</a/>/a/|/a/
            Debug.Print(Path.GetPathRoot(path));                                //输出:-----C:\
            Debug.Print(Path.GetRandomFileName());                              //输出:-----0am13z3o.gzd
            Debug.Print(Path.GetTempFileName());                                //输出:-----C:\Users\cks\AppData\Local\Temp\tmp81E5.tmp
            Debug.Print(Path.HasExtension(path).ToString());                    //输出:-----True
            Debug.Print(Path.IsPathRooted(path).ToString());                    //输出:-----True
            Debug.Print(Path.AltDirectorySeparatorChar.ToString());             //输出:-----/
            Debug.Print(Path.DirectorySeparatorChar.ToString());                //  输出:-----\
            Debug.Print(String.Join("/x/"Path.InvalidPathChars));             //输出:-----"/x/</x/>/x/|/x/
            Debug.Print(Path.PathSeparator.ToString());                         //输出:-----;
            Debug.Print(Path.VolumeSeparatorChar.ToString());                   //输出:-----:  
            // LuaDLL.getc(stdin);
            //test t = new test();
        } 

猜你喜欢

转载自blog.csdn.net/fengya1/article/details/53996101
今日推荐