file-copying

Why copying to system32 automatically copies to sysWOW64 instead?

陌路散爱 提交于 2019-12-04 03:17:53
问题 I'm trying to copy a file to C:\windows\system32 by calling CopyFileA - debugging shows that indeed the string "C:\windows\system32\filename" is sent to CopyFileA, but my file is copied to "C:\windows\system32\sysWOW64\filename" instead. Does anyone know why does that happen? 回答1: On 64bit Windows, Windows does filesystem redirection for 32bit processes. To disable, call Wow64DisableWow64FsRedirection For the app to also run on 32bit Windows XP, Wow64DisableWow64FsRedirection must be

Performant File Copy in C#?

余生颓废 提交于 2019-12-03 13:13:06
问题 I have a huge directory of about 500k jpg files, and I'd like to archive all files that are older than a certain date. Currently, the script takes hours to run. This has a lot to do with the very piss-poor performance of GoGrid's storage servers, but at the same time, I'm sure there's a way more efficient way Ram/Cpu wise to accomplish what I'm doing. Here's the code I have: var dirInfo = new DirectoryInfo(PathToSource); var fileInfo = dirInfo.GetFiles("*.*"); var filesToArchive = fileInfo

Copying files which the main thread adds to a stringlist using a thread

守給你的承諾、 提交于 2019-12-03 11:21:00
问题 I have a web creation program which, when building a site, creates hundreds of files. When the internet root folder is situated on the local pc, the program runs fine. If the internet root folder is situated on a network drive, the copying of a created page takes longer than creating the page itself (the creation of the page is fairly optimized). I was thinking of creating the files locally, adding the names of the created files to a TStringList and let another thread copy them to the network

Copy file even when destination exists (in Qt)

烈酒焚心 提交于 2019-12-03 10:46:38
In the QFile::copy documentation it says If a file with the name newName already exists, copy() returns false (i.e., QFile will not overwrite it). But I need to copy a file even if the destination exists. Any workaround available in Qt for that? Deleting the file is the obvious solution but it invites a race condition... karlphillip if (QFile::exists("/home/user/dst.txt")) { QFile::remove("/home/user/dst.txt"); } QFile::copy("/home/user/src.txt", "/home/user/dst.txt"); The obvious solution is of course to delete the file if it exists, before doing the copy. Note however that doing so opens up

How does one display progress of a file copy operation in Java. without using Swing e.g. in a Web app?

空扰寡人 提交于 2019-12-03 08:24:36
I have a web application which needs to perform a file copy operation and show user a progress bar. Currently, the copy is being done by calling cpio which cannot give progress to the Java code until after the operation has completed. While it would be possible to use Java to monitor the number of bytes written vs. number of bytes read for an estimate of the copy progress, I think there might be a simpler solution if I code the actual copy operation in Java. I would still use cpio for archiving purposes, but the actual copy would be performed by a Java class. Most of the help I found in my

FileChannel.transferTo for large file in windows

戏子无情 提交于 2019-12-03 05:18:04
问题 Using Java NIO use can copy file faster. I found two kind of method mainly over internet to do this job. public static void copyFile(File sourceFile, File destinationFile) throws IOException { if (!destinationFile.exists()) { destinationFile.createNewFile(); } FileChannel source = null; FileChannel destination = null; try { source = new FileInputStream(sourceFile).getChannel(); destination = new FileOutputStream(destinationFile).getChannel(); destination.transferFrom(source, 0, source.size())

Performant File Copy in C#?

限于喜欢 提交于 2019-12-03 03:24:50
I have a huge directory of about 500k jpg files, and I'd like to archive all files that are older than a certain date. Currently, the script takes hours to run. This has a lot to do with the very piss-poor performance of GoGrid's storage servers, but at the same time, I'm sure there's a way more efficient way Ram/Cpu wise to accomplish what I'm doing. Here's the code I have: var dirInfo = new DirectoryInfo(PathToSource); var fileInfo = dirInfo.GetFiles("*.*"); var filesToArchive = fileInfo.Where(f => f.LastWriteTime.Date < StartThresholdInDays.Days().Ago().Date && f.LastWriteTime.Date >=

Java 8: Copy directory recursively?

倾然丶 夕夏残阳落幕 提交于 2019-12-03 02:19:19
I see that Java 8 has significantly cleaned up reading the contents of a file into a String: String contents = new String(Files.readAllBytes(Paths.get(new URI(someUrl)))); I am wondering if there is something similar (cleaner/less code/more concise) for copying directories recursively. In Java 7 land, it's still something like: public void copyFolder(File src, File dest) throws IOException{ if(src.isDirectory()){ if(!dest.exists()){ dest.mkdir(); } String files[] = src.list(); for (String file : files) { File srcFile = new File(src, file); File destFile = new File(dest, file); copyFolder

Copying files which the main thread adds to a stringlist using a thread

感情迁移 提交于 2019-12-03 01:53:51
I have a web creation program which, when building a site, creates hundreds of files. When the internet root folder is situated on the local pc, the program runs fine. If the internet root folder is situated on a network drive, the copying of a created page takes longer than creating the page itself (the creation of the page is fairly optimized). I was thinking of creating the files locally, adding the names of the created files to a TStringList and let another thread copy them to the network drive (removing the copied file from the TStringList). Howerver, I have never, ever used threads

Copy-Item for copy files from local to remove server using credentials

北战南征 提交于 2019-12-02 10:12:58
问题 I am trying to copy some files and folder from my local machine to a remote server: Copy-Item .\copy_test.txt -destination "\\serverip\c$\backups\" but I'm getting an error: Copy-Item : Logon failure: unknown user name or bad password. At line:1 char:10 + Copy-Item <<<< .\copy_test.txt -destination "\\serverip\c$\backups\" -verbose + CategoryInfo : NotSpecified: (:) [Copy-Item], IOException + FullyQualifiedErrorId : System.IO.IOException,Microsoft.PowerShell.Commands.CopyItemCommand I was