常用类库---文件操作类

namespace _06Path
{
class Program
{
static void Main(string[] args)
{
//Directory.GetFiles(路径)
string[] temp = Directory.GetFiles(@"C:UsersHackerDesktopfile");//全路径
}
}
}

path类是一个静态类:专门针对路径字符串进行处理(针对的是字符串,与文件没有太大关系)

字符串处理有哪些方法

  ->Combine()

//在文件字符串拼接的时候帮你判断最后一个是否是斜杠 。这是如果第二 个参数也有路径,那么会以第二个参数为准   

    string path = @"G:windowsDebug";
    string name = @"jk123.doc";

    string file = Path.Combine(path,name);
    Console.WriteLine(file);
    Console.ReadKey();

    

  ->GetDirectoryName()

//得到文件夹的意思

  ->GetFileName()

相对路径是及其不安全的路径,那么就要找到一个绝对路径

  ->GetFullPath()

//相当于预处理的文件路径

 

FileStream类------文件流

 

原文地址:https://www.cnblogs.com/Maxq/p/5705968.html