T
Thomas Bauer
Hello,
Call
DeleteFiles bgW_DeleteFilesProcess = new DeleteFiles();
bgW_DeleteFilesProcess.RunAsync( folder, 5, "*.txt", new
RunWorkerCompletedEventHandler( RunWorkerCompleted_DeleteFiles_TXT ) );
I delete all files, which older than 5 days and I use a background
thread.
System.IO.FileInfo[] files = new
System.IO.DirectoryInfo( bw.Path ).GetFiles( bw.Extension,
System.IO.SearchOption.AllDirectories );
Array.ForEach( files, delegate( System.IO.FileInfo file )
{
if ( file.CreationTime.Date <= DateTime.Today.AddDays( -
bw.Days ) )
{
file.Delete();
FilesDeleted++;
}
} );
3 questions:
a)
If I move the files, only for test from folder a to b.
The member file.CreationTime.Date hvae the actual date.
Why that?
I want to use the creation date from the file.
b)
I found this in the net.
###Array.ForEach( files, delegate( System.IO.FileInfo file )#####
Is not claer for me
delegate( System.IO.FileInfo file ) ?
Why delegate?
Can I write another way. A easier way for understanding?
c) Extension
I will delete following files
"*.txt"
"*.log"
I can't say "*.txt, *log".
Is it possible to use both? If yes, how?
Regards Thomas
Call
DeleteFiles bgW_DeleteFilesProcess = new DeleteFiles();
bgW_DeleteFilesProcess.RunAsync( folder, 5, "*.txt", new
RunWorkerCompletedEventHandler( RunWorkerCompleted_DeleteFiles_TXT ) );
I delete all files, which older than 5 days and I use a background
thread.
System.IO.FileInfo[] files = new
System.IO.DirectoryInfo( bw.Path ).GetFiles( bw.Extension,
System.IO.SearchOption.AllDirectories );
Array.ForEach( files, delegate( System.IO.FileInfo file )
{
if ( file.CreationTime.Date <= DateTime.Today.AddDays( -
bw.Days ) )
{
file.Delete();
FilesDeleted++;
}
} );
3 questions:
a)
If I move the files, only for test from folder a to b.
The member file.CreationTime.Date hvae the actual date.
Why that?
I want to use the creation date from the file.
b)
I found this in the net.
###Array.ForEach( files, delegate( System.IO.FileInfo file )#####
Is not claer for me
delegate( System.IO.FileInfo file ) ?
Why delegate?
Can I write another way. A easier way for understanding?
c) Extension
I will delete following files
"*.txt"
"*.log"
I can't say "*.txt, *log".
Is it possible to use both? If yes, how?
Regards Thomas