File.Move large binary file

K

kids_pro

Hi,

How does File.Move implmented?
I am like to use it a lot but when I come a cross a large file >500 MB
my UI is freezed.

I think about implement my own fileMove function but I am not sure what
is the efficient way to implement it. There are many thing in the
System.IO such as BinaryRead, BinaryWrite FileStream etc.

Please advice me on how to handle file.move for large binary file.

Many thanks,
kids
 
T

Truong Hong Thi

Even if you implement your own function, UI is still likely to hang
unless you make use of async IO. I think it is better to still use
File.Move, but call it on a different thread.
 
W

William Stacey [MVP]

When the file is in the same partition, it is renamed. When on different
partitions, the file is copied and then deleted from source. For large
files, this is just going to take time, so I would not do this operation on
the UI thread. Create a backgroundworker.
 
K

kids_pro

William said:
When the file is in the same partition, it is renamed. When on different
partitions, the file is copied and then deleted from source. For large
files, this is just going to take time, so I would not do this operation on
the UI thread. Create a backgroundworker.
Is it possible to show the progress (in progress bar) during file move?
Go backgroundworker way.
 
T

Truong Hong Thi

More on this, note that you don't know the actual progress of
File.Move. You could guess that base on the file size, but it is not
exact. Maybe better just displaying a label saying file is copying.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top