file.move very slow

M

Matthew Eno

I have a problem where I'm developing some code that moves files from
one place to another (on the same drive) with the destination file
having a new name.

What's happening is that the line of code where I do the file.move is
taking a very long time (in the order of around 7 seconds for a simple
30kb file).

The only thing that I can think may be causing the problem is that
theere is around 1.1 million files to move, so perhaps it's the
operating system having to maintain the file system that is making it
take so long.

To find how long the file.move step is taking I'm just doing the
following:

starttime = Now.ToOADate * 100000
File.Move(DocPath,FileDestination)
endtime = Now.ToOADate * 100000
Console.WriteLine("Moved file " & DocPath & " (" & endtime - starttime
& " seconds)")

Does anyone know why it would be taking so long, and another question
- would performing a file.exists take a long time if there is such a
large number of files ?
 
D

DraguVaso

Hi,

I worked around a little bit with the File-object, and I did some tests with
large files ( +- 5 Mb)

- I used File.Move to rename a file: that worked very quick (less than a
second).
I didn't use it to really move a file over the network.

- I used File.Copy to copy files over the network, and that took me like 2
seconds for a 5Mb file.

- File.Exists: works fast (almost no time spoiled)

- Directory.Exists: works fast if the directory is there, but strange thing:
when the directory doesn't exist it takes easily 10 seconds :)

I hope I helped you a bit. I guess the fact that your File.Move takes so
much time is because of the resources of your computer/network. And give it
a try that File.Exists on that milion files, hehe. Let me know the result,
I'm curious :)

Pieter
 

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