Copy files without jamming the network

Asked

Viewed 202 times

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. Backup is manually performed 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 then, I developed a system (in c#) to perform this backup (SQL Server and Files) to run the night. The problem is that the company works 24 hrs a day, and the moment it starts copying the files the network gets congested and the system in Delphi does not run (it accesses the same server) and the company depends on this system to continue the activities.

Is it possible to connect to the server via a specific network port with c#? how to do this? Does anyone have any idea how to fix this?

Follows 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);
            }
        }
  • Are you sure that the problem is the network and that it is not your program that is consuming all the computer resources on which it is running (I/O on disk, database, memory and/or processing)?

  • Have a look at this link https://www.codeproject.com/Articles/18243/Bandwidth-throttling

  • 1

    @Diegorafaelsouza believe it is the network because even if I manually copy the folder (which contains approx. 190 GB) also congested and the system in Delphi does not work. Thank you for the reply and I will pay attention to these details....

  • @Leandroangelo thanks for the link, I’ll look...

  • o. The 190GB explains a lot if you have a network of 100 or 10Mbps...

  • 1

    @Diegorafaelsouza yes, it really explains... I don’t know much about networking, but I think that if I can maybe get Delphi to connect on one door and c# on another maybe one won’t get in the way of the other... But I don’t know how to do it or if it’s possible...

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.