如何在复制之前像Explorer那样为文件保留空间? (不包括FileStream.Length/Seek) [英] How to reserve space for a file like Explorer does before copying? (Excluding FileStream.Length/Seek)

查看:77
本文介绍了如何在复制之前像Explorer那样为文件保留空间? (不包括FileStream.Length/Seek)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何像复制之前资源管理器一样为文件保留空间?

我试图将大文件复制到USB闪存并断开线程,结果-每几秒钟创建了900MB文件,但BUT进程仍在运行,并且其存在时间等于复制文件的时间.

(不包括FileStream.Length/Seek的解决方案,因为它在闪存驱动器上速度很慢.)

How can we reserve space for a file, like Explorer does before copying?

I tried to copy big file to usb-flash and broke a thread, result - 900MB file was created per few seconds, BUT process still running and its existence time is equal to time for copying file.

(Solutions excluding FileStream.Length/Seek, because it''s slow on a flash drive.)

推荐答案

这是一个主意.为什么不先创建文件,然后用原始文件中的字节替换字节.这是一个可能有用的链接. http://bytes.com/topic/c-sharp/answer/701359-如何创建新文件固定大小.提到了几种方法,其中一种可能具有所需的属性.

创建一个空文件和复制一个空文件可能需要花费很长时间,但可能会出现问题,但是我认为这样做值得一试.

希望这会有所帮助.
Here is an idea. Why not create the file first and then replace the bytes with the ones from your original file. Here is a link that might help. http://bytes.com/topic/c-sharp/answers/701359-how-create-new-file-fixed-size. Several methods are mentioned and one might have the properties you want.

There could be issues as it might take just as long to create an empty file as to copy one, but I think that this might be worth a shot.

Hope this helps.
Ken


halabella写道:
halabella wrote:

保留空间



在哪里?在磁盘上?在资源管理器"面板上?

资源管理器不会保留任何磁盘空间,它会检查是否有足够的磁盘空间,但是如果由于某些其他活动而占用了磁盘空间,则复制过程仍然会失败.

:)



where? on disk? on the Explorer panel?

Explorer does not reserve any disk space, it checks sufficient disk space is available, however if that fills up due to some other activity the copy process will still fail.

:)


这篇关于如何在复制之前像Explorer那样为文件保留空间? (不包括FileStream.Length/Seek)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆