Copying files without congesting the network

2

When I joined the company, it already had servers, a stable network and a system developed in Delphi and everything working in the most perfect order. The backup is performed manually every day on an external hard drive.

Recently in a conversation with the owner it was suggested to implement automatic backup with another machine. until now, I developed a system (in C #) to perform this backup (SQL Server and Files) to run the night. The problem is that the company runs 24 hrs a day, and the moment it starts to copy the files the network gets congested and the system in Delphi does not run (it accesses the same server) and the company depends on that system to continue the activities.

Is it possible to connect to the server through a specified network port with C #? how to do this? Anyone have any ideas how to resolve this?

Follow the code:

public void CopiarDirSubDir(string DirOrigem, string DirDestino, bool copiarSubDir)
        {
            var dir = new DirectoryInfo(DirOrigem);
            var dirs = dir.GetDirectories();

            // If the source directory does not exist, throw an exception.
            if (!dir.Exists)
            {
                throw new DirectoryNotFoundException(" Diretório de Origem não existe ou não pode ser encontrado!: " + DirOrigem);
            }
            // If the destination directory does not exist, create it. 
            if (!Directory.Exists(DirDestino))
            {
                Directory.CreateDirectory(DirDestino);
            }
            // Get the file contents of the directory to copy. 
            var files = dir.GetFiles();
            foreach (var file in files)
            {
                // Create the path to the new copy of the file.
                var temppath = Path.Combine(DirDestino, file.Name);
                // Copy the file.
                file.CopyTo(temppath, true);
            }
            // If copySubDirs is true, copy the subdirectories.
            if (!copiarSubDir) return;
            foreach (var subdir in dirs)
            {
                // Create the subdirectory. 
                var temppath = Path.Combine(DirDestino, subdir.Name);
                // Copy the subdirectories.
                CopiarDirSubDir(subdir.FullName, temppath, copiarSubDir);
            }
        }
    
asked by anonymous 18.04.2018 / 19:48

0 answers