Hello Friends I am new to this programing world so please help me
I want to creat an application that CAN COPY FILES OF PARTICULAR MONTH
AS PER ITS LAST WRITEN DATE (LAST MODIFIYED DATE) FOR EXAMPLE
IF THERE IS A FOLDER IT CONTAIN LOTS OF FILES OF DIFRENNT MONTH
FORM THAT I WANT TO COPY ONLY 01/04/09 TO 30/04/09 FILES TO RESPECTED FOLDER . IN SHORT I WANT TO CREAT APPLICATION THAT CAN COPY DATE WISE BULK FILE TO OTHER FOLDERS.
Date wise Bulk File Copying Application Using C#
4 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Hirendra SisodiyaRank #256 · 9.8K pointsPosted Mar 25, 2010, 10:35 PM EDT
you can use this code
Assume startdate and enddate are your two date than:
Dim startdate As DateTime
Dim EndDate As DateTime
Dim FirstFolder_Path As String = "C:\Documents and Settings\hirendra\My Documents\FirstFolder\"
Dim SecondFolder_path As String = "C:\Documents and Settings\hirendra\My Documents\LastFolder\"
Dim _File As IO.File
Dim _dir As New IO.DirectoryInfo(FirstFolder_Path)
For Each file In _dir.GetFiles
Dim fileinfo As New IO.FileInfo(file.FullName)
If fileinfo.LastWriteTime > startdate And fileinfo.LastWriteTime < EndDate Then
file.CopyTo(SecondFolder_path & file.Name)
End If
Next
thanks
Please mark as answere if it helps
Bunty4 pointsPosted Mar 26, 2010, 3:25 AM EDT
thanks for giveing support but sir i know c sharp only so sorry sir i can now understand or use this codeing sir plz help me do develop in c sharp
thanx
Hirendra SisodiyaRank #256 · 9.8K pointsPosted Mar 28, 2010, 8:53 PM EDT
this is C# Code try this:
DateTime startdate;
DateTime EndDate;
string FirstFolder_Path = "C:\\Documents and Settings\\hirendra\\My Documents\\FirstFolder\\";
string SecondFolder_path = "C:\\Documents and Settings\\hirendra\\My Documents\\LastFolder\\";
IO.File _File = default(IO.File);
IO.DirectoryInfo _dir = new IO.DirectoryInfo(FirstFolder_Path);
foreach (var file in _dir.GetFiles)
{
IO.FileInfo fileinfo = new IO.FileInfo(file.FullName);
if (fileinfo.LastWriteTime > startdate & fileinfo.LastWriteTime < EndDate)
{
file.CopyTo(SecondFolder_path + file.Name);
}
}
thanks
Please mark as answere if it helps
anand sutar28 pointsPosted May 16, 2014, 3:48 AM EDT
Error1foreach statement cannot operate on variables of type 'method group' because 'method group' does not contain a public definition for 'GetEnumerator'
Error2Foreach cannot operate on a 'method group'. Did you intend to invoke the 'method group'?
Error3Cannot declare a variable of static type 'System.IO.File'