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.
Loading
anand sutarPosted May 16, 2014, 7:48 AM
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'
Hirendra SisodiyaPosted Mar 29, 2010, 12:53 AM
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
BuntyPosted Mar 26, 2010, 7:25 AM
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 SisodiyaPosted Mar 26, 2010, 2:35 AM
hello Bunty
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