gpt4 book ai didi

c# - System.IO.File 和 System.IO.FileInfo 有什么区别

转载 作者:太空宇宙 更新时间:2023-11-03 17:59:24 24 4
gpt4 key购买 nike

为什么有两个用于几乎相同目的的类 System.IO.File 和 System.IO.FileInfo。

最佳答案

System.IO.File提供与处理文件相关的静态成员,而 System.IO.FileInfo表示一个特定文件并包含用于处理该文件的非静态成员。

来自 MSDN:

Because all File methods are static, it might be more efficient to use a File method rather than a corresponding FileInfo instance method if you want to perform only one action. All File methods require the path to the file that you are manipulating.

The static methods of the File class perform security checks on all methods. If you are going to reuse an object several times, consider using the corresponding instance method of FileInfo instead, because the security check will not always be necessary.

关于c# - System.IO.File 和 System.IO.FileInfo 有什么区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4003233/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com