What is the difference between File and FileInfo in C#?

后端 未结 10 1685
我在风中等你
我在风中等你 2020-12-02 11:22

I\'ve been reading that the static methods of the File Class are better used to perform small and few tasks on a file like checking to see if it exists and that

10条回答
  •  一个人的身影
    2020-12-02 11:36

    Yes, and one of the reason could be is, as Nag said Files is a utility class and hence no instance is required to be created. Same time, as File being utility class, each time require security check.

    On other hand FileInfo requires instance to be created, and that point it uses security check. Thus, now performing multiple operation using FileInfo will not invoke security checks.

提交回复
热议问题