Walter.IO
TryRead Method
Walter.IO Assembly > Walter.IO Namespace > FileInfoExtensions Class : TryRead Method
The file to read.
Output parameter that receives the text read from the file.
Attempts to read the contents of a file into a string without acquiring an exclusive lock on the file.
Syntax
public static bool TryRead( 
   FileInfo file,
   out string? text
)

Parameters

file
The file to read.
text
Output parameter that receives the text read from the file.

Return Value

true if the file was successfully read; otherwise, false.
Remarks
This method facilitates reading file data for non-exclusive access, allowing other processes to access the file concurrently. Especially useful for applications that need to read files in use by other processes or for concurrent file access in a multi-threaded environment.
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

FileInfoExtensions Class
FileInfoExtensions Members