首先大致说说c#文件本地文件操作
在说之前我们知道一个文件.txt,excel,dll等都是保存在硬盘或叫磁盘上面,然后知道了c#是通过操作流来读取和写入这些文件 ——那么用这里就用到了两个重要的操纵。FileStream和StreamWrite,StreamReader,MemoryStream等,它们的引用空间是System.IO。
//读取文件.txt
using(Filestream fs = File.OpenRead(path))
{//读取byte位;
int length = fs.Length;
byte[] byteArray = new byte[length];
fs.Read(byteArray,0,length);
fs.Close();
}
或者直接修改字符串:
FileStream fs = File.OpenRead(path);
StreamWriter sw = new StreamWriter(fs);
sw.WriteLine(string);
sw.Close();
fs.Close();
然后我们说说在本地硬盘上面创建文件夹,这里用到Directory这个东东,用来操作file文件夹的。比如你想建一个文件夹:Directoy.CreateDirectory(@"c\Users\name\Destop\fileName");
删除的话
Directory.Delete(StringPath);