473,397 Members | 2,077 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

file.move very slow

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 ?
Nov 20 '05 #1
1 3026
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

"Matthew Eno" <ma**@enotechnologies.com> wrote in message
news:de**************************@posting.google.c om...
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 ?

Nov 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Brian Sabolik | last post by:
I'm not sure if I've broken any Object Oriented rules or not, but ... I have projects in 2 different solutions that need to use each other's methods. Therefore I may have an "update" method in...
7
by: spike | last post by:
Im writing a program to search for a string in a binary file. And it works. The problem is: It is sooo slow! how can i make it faster? It takes 27 seconds just to search a 5 meg file. I guess it...
1
by: Christoph Bisping | last post by:
Hello! Maybe someone is able to give me a little hint on this: I've written a vb.net app which is mainly an interpreter for specialized CAD/CAM files. These files mainly contain simple movement...
3
by: Adrian | last post by:
Hi, Before I open a file to read it etc how can I test to ensure it not currently in use by another process? the scenario is that I'm watch for a file to be created once it is I read its...
5
by: bulldog8 | last post by:
I've read numerous posts and have tried multiple approaches that I found, but just cannot get a file renamed. I am using VB.Net 2002 ... Here is what I have tried: 1) Code common to all...
1
AdrianH
by: AdrianH | last post by:
Assumptions I am assuming that you know or are capable of looking up the functions I am to describe here and have some remedial understanding of C programming. FYI Although I have called this...
9
by: =?Utf-8?B?QnJpYW4gQ29vaw==?= | last post by:
I want to open a text file and format it into a specific line and then apply color to a specific location of the text and then display it in a RichTextBox after all of this is done. I can do all...
2
by: BobF | last post by:
<given> When starting a new AJAX Control enabled site, a set of files are created. These are created -without- a master page. </given> To add a master page, I've been adding the master via...
2
by: Derik | last post by:
I've got a XML file I read using a file_get_contents and turn into a simpleXML node every time index.php loads. I suspect this is causing a noticeable lag in my page-execution time. (Or the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.