How to Copy Files Fast

The fastest version w/o overoptimizing the code I’ve got with the following code: class CTError(Exception): def __init__(self, errors): self.errors = errors try: O_BINARY = os.O_BINARY except: O_BINARY = 0 READ_FLAGS = os.O_RDONLY | O_BINARY WRITE_FLAGS = os.O_WRONLY | os.O_CREAT | os.O_TRUNC | O_BINARY BUFFER_SIZE = 128*1024 def copyfile(src, dst): try: fin = os.open(src, READ_FLAGS) stat … Read more

File Copy with Progress Bar

You need something like this: public delegate void ProgressChangeDelegate(double Percentage, ref bool Cancel); public delegate void Completedelegate(); class CustomFileCopier { public CustomFileCopier(string Source, string Dest) { this.SourceFilePath = Source; this.DestFilePath = Dest; OnProgressChanged += delegate { }; OnComplete += delegate { }; } public void Copy() { byte[] buffer = new byte[1024 * 1024]; // … Read more

Copying files from Docker container to host

In order to copy a file from a container to the host, you can use the command docker cp <containerId>:/file/path/within/container /host/path/target Here’s an example: $ sudo docker cp goofy_roentgen:/out_read.jpg . Here goofy_roentgen is the container name I got from the following command: $ sudo docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 1b4ad9311e93 … Read more

Java 8: Copy directory recursively?

In this way the code looks a bit simpler import static java.nio.file.StandardCopyOption.*; public void copyFolder(Path src, Path dest) throws IOException { try (Stream<Path> stream = Files.walk(src)) { stream.forEach(source -> copy(source, dest.resolve(src.relativize(source)))); } } private void copy(Path source, Path dest) { try { Files.copy(source, dest, REPLACE_EXISTING); } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } … Read more

How to copy a file while it is being used by another process

An Example (note: I just combined two google results, you may have to fix minor errors ;)) The important part is the FileShare.ReadWrite when opening the FileStream. I use a similar code to open and read Excel documents while excel is still open and blocking the file. using (var inputFile = new FileStream( “oldFile.txt”, FileMode.Open, … Read more

Command copy exited with code 4 when building – Visual Studio restart solves it

While /C may ignore errors, it might not be the real solution as there could be files that MUST be copied in order for the build to be successful. The most common issue is the missing quotes around the pre-defined command tags (such as $TargetDir). When one creates various branches and paths in code or … Read more

Docker: Copying files from Docker container to host

In order to copy a file from a container to the host, you can use the command docker cp <containerId>:/file/path/within/container /host/path/target Here’s an example: $ sudo docker cp goofy_roentgen:/out_read.jpg . Here goofy_roentgen is the container name I got from the following command: $ sudo docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 1b4ad9311e93 … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)