You must Sign In to post a response.
  • Category: .NET

    Bakup the file month wise

    Hi,

    How to backup the files every month at once. If folder name should be in year with month.

    how can i do this.
  • #712077
    http://www.dotnetutorial.com/display-code.aspx?id=25
    Regards,
    Programmer

    http://www.dotnetutorial.com/interview-questions.aspx?catid=1

  • #712083
    backup files in hard disk to another location or is it database backup ?
    Regards,
    Shine

  • #712092
    Hi shine,

    Yes, it is database backup. I am using MS Access database. I want to take backup every month.

    -----------------------------------------------------------------------------
    Regards,
    Gopi A.
    +91 9894315571
    Skype:gopi.net
    http://asaigopi-dotnet.blogspot.in/

  • #712101
    Hi.,

    Try like this,



    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    Dim sDBFile As String = "E:\myDB.mdb"

    Dim sBackUpFile As String = "T:\DBbackups " & format(Date, "ddMMyy")

    If File.Exists(sBackUpFile) Then

    File.Copy(sBackUpFile, sDBFile, True)

    End If



    End Sub


    Regards,
    Gandhi

  • #712109
    since excel database is stored as standalone mdb files you can use simple file copy application. see the below code



    private void button1_Click(object sender, EventArgs e)
    {
    CopyFile(@"D:\Sample.mdb");
    }

    private void CopyFile(string strSource)
    {
    string strBackupFolderName = DateTime.Now.Year.ToString() + "-" + DateTime.Now.Month.ToString();

    if (!Directory.Exists(@"D:\strBackupFolderName"))
    {
    //create directory

    Directory.CreateDirectory(@"D:\" + strBackupFolderName);
    }


    if (File.Exists(strSource))
    {
    FileInfo fi = new FileInfo(strSource);

    string strBackupPath = Path.Combine(@"D:\" + strBackupFolderName, fi.Name);
    File.Copy(strSource, strBackupPath, true);
    fi = null;
    }

    }

    Regards,
    Shine


  • This thread is locked for new responses. Please post your comments and questions as a separate thread.
    If required, refer to the URL of this page in your new post.