Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > How to move directory ( with contents) to another directory.

Reply
Thread Tools

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

 
 
mike
Guest
Posts: n/a
 
      03-14-2008
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().toS tring());
tmpDir = new File (nonCCResource.getParent().getLocation().toString( ),
nonCCResource.getName()+".tmp");
boolean success = tmpDir.mkdirs();
File dir = new
File(nonCCResource.getParent().getLocation().toStr ing(),
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
 
Reply With Quote
 
 
 
 
Andrew Thompson
Guest
Posts: n/a
 
      03-14-2008
On Mar 15, 4:55*am, mike <(E-Mail Removed)> wrote:
...
> 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
 
Reply With Quote
 
 
 
 
Roedy Green
Guest
Posts: n/a
 
      03-15-2008
On Fri, 14 Mar 2008 10:55:19 -0700 (PDT), mike
<(E-Mail Removed)> 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.
--

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

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Writing move constructors and move assignment Andrew Tomazos C++ 2 12-12-2011 01:45 PM
Directory.CreateDirectory followed by Directory.Move Matt MacDonald ASP .Net 0 01-30-2008 07:34 PM
System.IO.Directory.GetDirectories() and System.IO.Directory.GetFiles() are not returning the specified directory Nathan Sokalski ASP .Net 2 09-06-2007 03:58 PM
I am trying to move spaces to a weblistbox and when I move them... Eduardo78 ASP .Net Web Controls 0 11-03-2005 06:06 PM



Advertisments