• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Move a directory?

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi, i am trying to move a directory from c:\ to d:\. right now i am using this code:



this works fine, as long as i try to move the dir from c:\ to c:\programs or from c:\prgrams to c:\programs\hello. but as soon as i change the partition (c:\ to d:\) success is always false. can you imagine why?

THANKS
 
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Andreas,

you can't rely on that. JavaDoc says:

Whether or not this method can move a file from
one filesystem to another is platform-dependent.



That's it. As to your question why: because it is the
documented behaviour of the function. I am affraid you
will have to copy file by file and then at the end
remove the source.

Petr
 
Max Power
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello, oh i see. but what if i do not have the permission to delete the directory after copying it?

thanks :-)
 
Petr Blahos
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The only thing I can tell you is:
It is not trivial to move a directory. Many things can go
wrong and this permission to delete is only one of them.
You can:
- notify user that it was copied but not removed (I think
most file managers would do this)
- delete what you have copied so far
- ask user what to do
- ...

P.
 
reply
    Bookmark Topic Watch Topic
  • New Topic