Skip to content

File

File 类可以用来操作文件。它提供了一组静态方法,用于创建、复制、移动、重命名、删除文件等常见操作。

静态方法

File.Exists ( path : string ) : boolean
判断指定的文件是否存在。
File.GetParent ( path : string ) : string
获取指定路径的父文件夹名字。
File.Create ( path : string ) : void
创建指定路径的文件。
File.ReadAllText ( path : string ) : string
读取并返回指定路径的文件中的所有字符。
File.Delete ( path : string ) : void
删除指定路径的文件。
File.Move ( src : string , dst : string ) : void
移动源文件到指定路径。
File.Copy ( src : string , dst : string ) : void
复制源文件到指定目录。
File.ReadAllBytes ( path : string ) : MemoryStream|undefined
读取并返回指定路径的文件中的所有数据到内存流中。
File.WriteAllBytes ( path : string , data : MemoryStream ) : boolean
将内存流数据内容写入指定路径的文件中(覆盖原内容)。
File.WriteAllText ( path : string , content : string ) : void
将文本内容写入指定路径的文件中(覆盖原内容)。