《C#入门经典(中文第四版)》第18章:图形图像程序设计
---------------------------------------------------------------------------------------------------------
System.IO 命名空间
A1 ………… File 类
举例:通过时间创建文件夹及文件,并写入内容!
A2 ………… Directory 类
A3 ………… Path 类
A4 ………… StreamReader 类
A5 ………… StreamWriter 类
A6 ………… FileWriter 类
A7 ………… FileStream 类
A8 ………… FileInfo 类
A9 ………… DirectoryInfo 类
G1 ………… FileSystemInfo 类
---------------------------------------------------------------------------------------------------------
System.IO 命名空间
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第A1个 ╠══════════════════════════════════════════════════╣
╚════════╝
●·● File 类:
1. FileStream 对象。
2. File 方法(s):
- Copy(String, String):复制指定文件到新文件夹。不允许覆盖同名的文件。【路径要存在】
- Copy(String, String, Boolean): 允许覆盖同名的文件。【true】
- Create:
using (FileStream fs = File.Create(path, 1024))
{
Byte[] info = new UTF8Encoding(true).GetBytes("This is some text in the file.");
// Add some information to the file.
fs.Write(info, 0, info.Length);
}