Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / March 2008

Tip: Looking for answers? Try searching our database.

How to move directory ( with contents) to another directory.

Thread view: 
mike - 14 Mar 2008 18:55 GMT
I am trying to move a directory ( and it's contents to a new
directory). I have tried the following:

System.out.println(nonCCResource.getLocation().toString());
tmpDir = new File (nonCCResource.getParent().getLocation().toString(),
nonCCResource.getName()+".tmp");
boolean success = tmpDir.mkdirs();
File dir = new
File(nonCCResource.getParent().getLocation().toString(),
nonCCResource.getName());
boolean success1 = dir.renameTo(tmpDir);

When checking success1 it is false. And the success is true.

Any ideas how I can do this.

cheers,

//mike
Andrew Thompson - 15 Mar 2008 00:55 GMT
...
> Any ideas how I can do this.

My guess would be that Java (or the OS) will
not allow us to rename a directory to the name
of an existing directory.

Post runnable code and I might check further.

--
Andrew T.
PhySci.org
Roedy Green - 15 Mar 2008 05:06 GMT
On Fri, 14 Mar 2008 10:55:19 -0700 (PDT), mike
<mikaelpetterson@hotmail.com> wrote, quoted or indirectly quoted
someone who said :

>I am trying to move a directory ( and it's contents to a new
>directory). I have tried the following:

You can't rename a directory to move it to a different drive.  You
must have permissions on it to rename it.

To move it to a different drive, you have to create a new dir, copy
the files over, and then delete the original files and directory.

If you want help from others, simplify your code to use hard coded
strings or at least do println of each of your files so people can
what the net result of your calls is.
Signature


Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.