Yes, it is "safe." This is considered at a very low level - the file system driver. A file on shared file systems, such as FAT or NTFS, has two different structures on disk. First there is an entry in the directory, it stores metadata about the file. Like name, timestamps, attributes and length. Actual file data is stored elsewhere, a cluster chain in which file data is stored.
FileInfo exclusively provides you with metadata for the file. File data is much more sensitive, very subject to change, as the process writes to the file. It is noteworthy that you can block access to file data using the FileShare options. But there is no way to block metadata. Accordingly, you can always get FileInfo for a file, regardless of what another process is doing with the file.
Of course, the actual properties of FileInfo can be changed when a process is written to a file. They are updated lazily, especially the LastAccessTime property. If you want to be sure that you have accurate information that cannot be changed, you need to get a file lock. Do this by opening the file with FileShare.Read or FileShare.None. This ensures that no other process can open the file for writing if you have a file open. Please note that this can easily raise an IOException, you will only get a lock when another process hasnβt appeared before you and opened the file for writing.
Hans passant
source share