0

I want to rename large files while using c#. If I have a couple of large files and if I use .IO.move function my files will be copied with the right name and the old ones will be destroyed. that will take a veryyyy long time with large files

I couldnt find a good solution. anyone an idea fitting large files?

  • 1
    If you move from one volume to another, it is a copy + delete, which is unavoidable. – Joe Dec 29 '11 at 21:00

3 Answers3

6

Whatever solution you choose - if you move your file between different logical/physical disks - you cannot do anything with it. It takes some time to move the data.

zerkms
  • 249,484
  • 69
  • 436
  • 539
  • Maybe i was a bit unclear, i want to rename a file,but i dont want to do things with the file that will cost a lot of time, like using the .io.move(oldname,newname) method – ComputerIntelligentAgent Dec 29 '11 at 21:01
  • because that method will move and delete stuff, which in this case having a couple of gigabytes to handle, isnt fast – ComputerIntelligentAgent Dec 29 '11 at 21:04
  • @ComputerIntelligentAgent: as long as you move files between different disks - it will always take a time to read-and-write all the file's bytes – zerkms Dec 29 '11 at 21:17
2

Have you tested your assumption? I did, and I found that if you use System.IO.File.Move, and the target location is on the same physical logical disk as the source, the file is just renamed. It doesn't take a long time.

phoog
  • 42,068
  • 6
  • 79
  • 117
1

You can create a new hardlink, then delete the original. This will only affect filesystem metadata, and not copy the file around.

Community
  • 1
  • 1
Jacob Krall
  • 28,341
  • 6
  • 66
  • 76