Skip to content

Date wise Bulk File Copying Application Using C#

Bunty

Asked Mar 25, 2010, 6:52 AM EDT4 answers
Share
LinkedInX
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.

4 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • Hirendra Sisodiya
    0
    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
    0
  • 0
    Hello sir
    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
    0
  • Hirendra Sisodiya
    0
    Hello Bunty
    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
    0
  • 0
    Hi this c# code not working properly Because of having some Error 

    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'


    0