下面介绍两个函数:
-
File.AppendAllText (String, String)
-
File.AppendAllText (String, String, String)
File.AppendAllText 方法 (String, String)
函数说明:打开一个文件,向其中追加指定的字符串,然后关闭该文件。 如果文件不存在,此方法创建一个文件,将指定的字符串写入文件,然后关闭该文件。
命名空间: System.IO
程序集: mscorlib(在 mscorlib.dll 中)
语法:
public static void AppendAllText( string path, string contents )
参数说明:
path
类型:System.String,要将指定的字符串追加到的文件。
contents
-
类型:
System.String,
要追加到文件中的字符串。
代码示例:
下面的代码示例演示如何使用 AppendAllText 方法将额外的文本添加到文件末尾。 在此示例中ÿ