C#文件复制回滚 [英] C# File Copy Rollback
问题描述
大家好,
有人抛出异常时,是否有人知道如何在文件复制中实现回滚功能.
复制文件时,有一些条件:
1.将文件复制到共享文件夹
2.文件大小不超过3MB
3.文件是图像文件(jpg,jpeg,bmp,gif,png)
4.防止文件名重复
5.操作系统在Windows XP和更高版本中
6.代码在Visual Studio 2010 Professional中的C#.Net 4.0上
7.网络连接是局域网
8.多个文件要复制
请帮忙.
在此先谢谢您.
Hi everyone,
Does anyone know how to implement a rollback function in file copying when an exception is thrown.
Here are some conditions when I copy the files:
1. Copy the file to a shared folder
2. File is no greater than 3MB
3. File is an image file (jpg, jpeg, bmp, gif, png)
4. Prevention of file name duplicate is already implemented
5. OS is in Windows XP and higher
6. Code is on C# .Net 4.0 in Visual Studio 2010 Professional
7. Network connection is Local Area Network
8. Multiple files to copy
Please help.
Thanks in advance.
推荐答案
维护已成功复制的文件列表,并在catch块中将其删除以供您的异常处理程序使用.还有什么您不提的吗?
Maintain a list of files that were successfully copied and delete them in the catch block for your exception handler. Is there something else you are not mentioning?
这篇关于C#文件复制回滚的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!