file-copying

How to bring up the built-in File Copy dialog?

江枫思渺然 提交于 2019-11-27 01:58:19
I'll be copying a large file over the network using my winforms app and I need to show some kind of progress bar. Rather than cook up my own copy routine, I was thinking that it might be better to simply show the built-in file copy dialog. I would also need a "Copy complete" and "Copy failed" notification. I need this to work on Windows XP, Vista and 7. Is there a way to call to engage this functionality from my c# code? ja72 Answer taken from: here Windows Vista does indeed include a new copy engine that supports exactly what you're looking to do. However, it's possible that previously

How do I copy a remote image in python?

这一生的挚爱 提交于 2019-11-27 01:08:43
问题 I need to copy a remote image (for example http://example.com/image.jpg ) to my server. Is this possible? How do you verify that this is indeed an image? 回答1: To download: import urllib2 img = urllib2.urlopen("http://example.com/image.jpg").read() To verify can use PIL import StringIO from PIL import Image try: im = Image.open(StringIO.StringIO(img)) im.verify() except Exception, e: # The image is not valid If you just want to verify this is an image even if the image data is not valid: You

File Copy with Progress Bar

老子叫甜甜 提交于 2019-11-27 00:26:58
I used this code: using System; using System.Collections.Generic; using System.ComponentModel; using System.Windows.Forms; using System.IO; namespace WindowsApplication1 { public partial class Form1 : Form { // Class to report progress private class UIProgress { public UIProgress(string name_, long bytes_, long maxbytes_) { name = name_; bytes = bytes_; maxbytes = maxbytes_; } public string name; public long bytes; public long maxbytes; } // Class to report exception { private class UIError { public UIError(Exception ex, string path_) { msg = ex.Message; path = path_; result = DialogResult

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

和自甴很熟 提交于 2019-11-26 09:00:46
问题 Is it possible to copy a file which is being using by another process at the same time? I ask because when i am trying to copy the file using the following code an exception is raised: System.IO.File.Copy(s, destFile, true); The exception raised is: The process cannot access the file \'D:\\temp\\1000000045.zip\' because it is being used by another process. I do not want to create a new file, I just want to copy it or delete it. Is this possible? 回答1: An Example (note: I just combined two

File Copy with Progress Bar

我的梦境 提交于 2019-11-26 08:07:16
问题 I used this code: using System; using System.Collections.Generic; using System.ComponentModel; using System.Windows.Forms; using System.IO; namespace WindowsApplication1 { public partial class Form1 : Form { // Class to report progress private class UIProgress { public UIProgress(string name_, long bytes_, long maxbytes_) { name = name_; bytes = bytes_; maxbytes = maxbytes_; } public string name; public long bytes; public long maxbytes; } // Class to report exception { private class UIError {

Copying files from Docker container to host

你离开我真会死。 提交于 2019-11-26 00:45:07
问题 I\'m thinking of using Docker to build my dependencies on a Continuous Integration (CI) server, so that I don\'t have to install all the runtimes and libraries on the agents themselves. To achieve this I would need to copy the build artifacts that are built inside the container back into the host. Is that possible? 回答1: 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

How do I copy a file in Python?

被刻印的时光 ゝ 提交于 2019-11-25 21:48:47
问题 How do I copy a file in Python? I couldn\'t find anything under os. 回答1: shutil has many methods you can use. One of which is: from shutil import copyfile copyfile(src, dst) Copy the contents of the file named src to a file named dst . The destination location must be writable; otherwise, an IOError exception will be raised. If dst already exists, it will be replaced. Special files such as character or block devices and pipes cannot be copied with this function. src and dst are path names

Copying files from Docker container to host

眉间皱痕 提交于 2019-11-25 20:01:19
I'm thinking of using Docker to build my dependencies on a Continuous Integration (CI) server, so that I don't have to install all the runtimes and libraries on the agents themselves. To achieve this I would need to copy the build artifacts that are built inside the container back into the host. Is that possible? creack 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 name I got from the following