C# Get Read Only Files
The following code will retrieve the read-only files using LINQ and C#
private static void GetFilesFromDirectory(string DirPath)
{
try
{
DirectoryInfo Dir = new DirectoryInfo(DirPath);
FileInfo[] FileList = Dir.GetFiles("*.*", SearchOption.TopDirectoryOnly );
var query = from FI in FileList
where FI.IsReadOnly == true
select FI.FullName + " " + FI.LastWriteTime;
foreach (string s1 in query )
{
Console.WriteLine(s1);
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message );
}
}
The above can (and mostly is) done by the following way
FileInfo[] FileList = Dir.GetFiles("*.*", SearchOption.TopDirectoryOnly );
foreach (FileInfo F1 in FileList)
{
if (F1.IsReadOnly == true)
{
Console.WriteLine(F1.FullName );
}
}
List ReadOnly files using C#, Retrieve Read-Only files using C#, Get Read Only Files using C#, List ReadOnly files using .NET, Retrieve Read-Only files using .NET, Get Read Only Files using .NET
No comments:
Post a Comment