Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8324985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:16:33+00:00 2026-06-09T00:16:33+00:00

I am trying to build a automatic backup and restore system. My logfile: 2012-08-02

  • 0

I am trying to build a automatic backup and restore system.

My logfile:

2012-08-02 22:34:06 - Init: Folder main created for server Teamdeathmatch
2012-08-02 22:34:06 - Backup: Couldn't copy files: System.UnauthorizedAccessException: Access to the path 'C:/temp/backups/Teamdeathmatch/server/main' is denied.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.File.InternalCopy(String sourceFileName, String destFileName, Boolean overwrite)
   at System.IO.File.Copy(String sourceFileName, String destFileName, Boolean overwrite)
   at BackupRollback.Backup.getServerFiles() in C:\Users\jordi\Desktop\ConsoleApplication1 - kopie\Backup.cs:line 51

The target and the file exist.

I hope that anyone can help me. Also some feedback about my programming of c# since c-sharp is new for me.

Thank you

class Backup
{

    public static void getServerFiles()
    {

        Log.Info("Get servers");
        string[] fileEntries = Directory.GetDirectories("c:/Gameservers");

        Log.Info("Servers found: " + fileEntries.Count());

        string _directoryPath = @"C:\temp\backups";

        // check folder exists
        if (!Directory.Exists(_directoryPath))
        {
            Log.Data("Temp backup folder not found");
            Directory.CreateDirectory(_directoryPath);
            Log.Data("Temp backup folder created successfully");

        }
        else
        {
            Log.Data("Temp backup folder found");
        }

        // move files to directory
        foreach (string fileName in fileEntries)
        {
            try
            {
                string servername = Path.GetFileNameWithoutExtension(fileName);

                Directory.CreateDirectory("C:/temp/backups/" + servername + "/server");
                Log.Data("Folder server created for server " + servername);

                Directory.CreateDirectory("C:/temp/backups/" + servername + "/server/main");
                Log.Data("Folder main created for server " + servername);

                File.Copy("C:/temp/backups/" + servername + "/server/main", "C:/Gameservers/" + servername + "/server/main/server.cfg");
                Log.Data("File server.cfg copied for server " + servername);

                Directory.CreateDirectory("C:/temp/backups/" + servername + "/b3 server/conf");
                Log.Data("Folder conf [b3] created for server " + servername);

                File.Copy("C:/temp/backups/" + servername + "/server/main", "C:/Gameservers/" + servername + "/b3 server/conf/b3.xml");
                Log.Data("File b3.xml copied for server " + servername);

                Directory.CreateDirectory("C:/temp/backups/" + servername + "/server/mods");
                Log.Data("Folder mods created for server " + servername);

                DirectoryCopy("C:/temp/backups/" + servername + "/server/", "C:/Gameservers/mods/" + servername + "/server/mods/");
                Log.Data("Folder mods copied for server " + servername);
            }

            catch (Exception ex)
            {
                Log.Data("Couldn't copy files: " + ex.ToString());
            }
        }


    }

    private static void DirectoryCopy(string sourceDirName, string destDirName)
     {
      DirectoryInfo dir = new DirectoryInfo(sourceDirName);
      DirectoryInfo[] dirs = dir.GetDirectories();

        FileInfo[] files = dir.GetFiles();

           foreach (FileInfo file in files)
          {
             string temppath = Path.Combine(destDirName, file.Name);

             file.CopyTo(temppath, false);
         }

         foreach (DirectoryInfo subdir in dirs)
        {
            string temppath = Path.Combine(destDirName, subdir.Name);

            DirectoryCopy(subdir.FullName, temppath);
        }
    }

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T00:16:36+00:00Added an answer on June 9, 2026 at 12:16 am

    File.Copy(source, destination)

    You have your parameters reversed. Try this instead.

    File.Copy"C:/Gameservers/" + servername + "/server/main/server.cfg",
             "C:/temp/backups/" + servername + "/server/main"); 
    Log.Data("File server.cfg copied for server " + servername); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to TFS and trying to do my first automatic build through the
I am trying to set up an automated build system on Windows using Cygwin.
I'm trying to build a system using jqgrid which does everything on the clientside,
I'm trying to build an automatic testing framework (based on jUnit, but that's no
I am trying to setup an automated build of my Windows CE application. However,
I'm trying to automate the build of a project in Delphi 2009. I'm using
I'm trying to automate a VB6 build where different apps are built from the
I'm trying to automate InstallShield from my build process, and I need to set
I am trying build a jQuery EasyUI datagrid or treegrid out of a large
I was trying Build For Archiving application (from Titanium Mobile) with xCode 4.4, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.