Something like this outta do it.
using System.IO;
string[] files = Directory.GetFiles(dirName);
foreach (string file in files)
{
FileInfo fi = new FileInfo(file);
if (fi.LastAccessTime < DateTime.Now.AddMonths(-3))
fi.Delete();
}
More Related Contents:
- Better way to check if a Path is a File or a Directory?
- How to get files in a relative path in C#
- How do I get the directory from a file’s full path?
- C# Searching for files and folders except in certain folders
- Is there a way to check if a file is in use?
- Easiest way to read from and write to files
- Checking for directory and file write permissions in .NET
- Nested using statements in C#
- How to change the timeout on a .NET WebClient object
- How to find the most recent file in a directory using .NET, and without looping?
- Best way to resolve file path too long exception
- What is the difference between Directory.EnumerateFiles vs Directory.GetFiles?
- C# – Get a list of files excluding those that are hidden
- Mirroring console output to a file
- Why does Path.Combine not properly concatenate filenames that start with Path.DirectorySeparatorChar?
- How can I create a temp file with a specific extension with .NET?
- How to remove a single Attribute (e.g. ReadOnly) from a File?
- Retrieving files from directory that contains large amount of files
- How to insert characters to a file using C#
- Is there a faster way than this to find all the files in a directory and all sub directories?
- Check if an executable exists in the Windows path
- Getting current directory in .NET web application
- Read random line from a file? c#
- Find all files in a folder
- Remove readonly attribute from directory
- Exclude certain file extensions when getting files from a directory
- Given full path, check if path is subdirectory of some other path, or otherwise
- C#: How to open Windows Explorer windows with a number of files selected
- Encrypt SQLite database in C#
- Method to get all files within folder and subfolders that will return a list