file-copying

How to write a call back function for ignore in shutil.copytree

冷暖自知 提交于 2019-12-10 03:19:01
问题 I am relatively new to python. I am trying to copy a directory to another directory maintaining the structure. I am using shutil.copytree(src, dst, symlinks=False, ignore=None, copy_function=copy2, ignore_dangling_symlinks=False) I am trying to write a call back function for ignore. My aim is to take a list of files in a list , and copy only those files,ignoring the rest. How do we pass a list into the call back function? I wrote a simple call back function , but I get some error when I try

Java 8: Copy directory recursively?

馋奶兔 提交于 2019-12-09 04:31:02
问题 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

Copying a file to/from external storage

删除回忆录丶 提交于 2019-12-08 12:47:34
I'm fairly new to Android and am having an writing to a certain file. What I'm trying to do is use the TextToSpeech.synthesizeToFile() method to write an audio file. This is working except for the fact that when the app exits the TextToSpeech engine automatically deletes the file it created. So I then tried to make a copy of the created file in another directory. To do this I use the copyFile() method of the org.apache.commons.io.FileUtils package. Using this method only results in a newly created file of 0 in size. I'm using Environment.getExternalStorageDirectory() to get the appropriate

Copying selected lines from files in different directories to another file

早过忘川 提交于 2019-12-08 09:08:54
问题 I have a directory with many subdirectories, containing files. I want to open the files ending with "root.vrpj" or "root.vprj", in "App_integrations" folder and copy the lines containing the word "table" to another file. Until now I've managed to visit each file with this code: for root, dirs, files in os.walk(movedir): for filename in files: if filename.endswith(("root.vrpj", "root.vprj")): The problem is that what I have now are just the names of the files I want to visit and I'm stuck here

Copying a file to/from external storage

醉酒当歌 提交于 2019-12-08 08:46:54
问题 I'm fairly new to Android and am having an writing to a certain file. What I'm trying to do is use the TextToSpeech.synthesizeToFile() method to write an audio file. This is working except for the fact that when the app exits the TextToSpeech engine automatically deletes the file it created. So I then tried to make a copy of the created file in another directory. To do this I use the copyFile() method of the org.apache.commons.io.FileUtils package. Using this method only results in a newly

Android: Copying tar file from assets to sdcard - IOException

自闭症网瘾萝莉.ら 提交于 2019-12-08 07:42:29
问题 I am trying to copy a .tar file from android assets to sdcard but while copying file I am getting IOException. I am using this code from a previous thread How to copy files from 'assets' folder to sdcard? Here is LogCat file. I am doing all this in ASyncTask but I have also tried it on main UI thread and still getting this exception. 01-11 06:51:49.925: E/tag(3881): Failed to copy asset file: temp.tar 01-11 06:51:49.925: E/tag(3881): java.io.IOException 01-11 06:51:49.925: E/tag(3881): at

Method for copying large amounts of data in C#

自闭症网瘾萝莉.ら 提交于 2019-12-07 14:19:56
问题 I am using the following method to copy the contents of a directory to a different directory. public void DirCopy(string SourcePath, string DestinationPath) { if (Directory.Exists(DestinationPath)) { System.IO.DirectoryInfo downloadedMessageInfo = new DirectoryInfo(DestinationPath); foreach (FileInfo file in downloadedMessageInfo.GetFiles()) { file.Delete(); } foreach (DirectoryInfo dir in downloadedMessageInfo.GetDirectories()) { dir.Delete(true); } } //======================================

Semaphore timeout period has expired

独自空忆成欢 提交于 2019-12-06 04:06:11
问题 I have a simple C# program that copies files from one network share to another. The program just threw a "The semaphore timeout period has expired" error. I've never seen this before and I'm kind of confused as to what it is. The code is pretty simple: (srcPath and destPath are read from configuration settings) DirectoryInfo di = new DirectoryInfo(srcPath); try { FileInfo[] files = di.GetFiles(); foreach (FileInfo fi in files) { if(!(fi.Name.Contains("_desc"))) { File.Copy(fi.FullName,

Method for copying large amounts of data in C#

混江龙づ霸主 提交于 2019-12-06 01:13:46
I am using the following method to copy the contents of a directory to a different directory. public void DirCopy(string SourcePath, string DestinationPath) { if (Directory.Exists(DestinationPath)) { System.IO.DirectoryInfo downloadedMessageInfo = new DirectoryInfo(DestinationPath); foreach (FileInfo file in downloadedMessageInfo.GetFiles()) { file.Delete(); } foreach (DirectoryInfo dir in downloadedMessageInfo.GetDirectories()) { dir.Delete(true); } } //================================================================================= string[] directories = System.IO.Directory.GetDirectories

How can I copy/replace a DLL?

好久不见. 提交于 2019-12-05 22:13:27
问题 I have a utility which updates applications by simply copying/replacing the executables. Now, I have some DLL files which need to be updated as well. However, sometimes Windows will not let me replace it because something is using it, and sometimes there's so many things using the DLL that I cannot guarantee it will be unlocked for me to replace it. Currently, my only work-around is to re-name the existing DLL first, and then I can copy the new one in its place. But then the old DLL gets left