• Post Reply Bookmark Topic Watch Topic
  • New Topic

Anyone tried using FileUtils to copy file from C:/ to G:/?  RSS feed

 
cle tan
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
a. copy files from C:/ to G:/

b. copy files from C:/ to shared drive J:/

I tried to copy there was no file seen and no exception.


File f2=new File("C:\\temp\\rx.txt");
File f1=new File("G:\\folder1")
FileUtils.copyFileToDirectory(f2, f1);

Permissions have been added but not sure why still unable to copy.
 
Dave Tolls
Ranch Foreman
Posts: 3068
37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is drive G?
Is it a disk on the same machine, or is it a network drive?
 
Indigo Montes
Greenhorn
Posts: 22
1
C++ IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I try your code it does copy a text file to another directory.
So probably something goes wrong in your case. Can you post your real code? The copyFileToDirectory call is probably located in a try-catch block. Do you print or log any possible exceptions? Is your catch block empty? Do you have access to write to G:\ ?
 
cle tan
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Indigo Montes wrote:When I try your code it does copy a text file to another directory.
So probably something goes wrong in your case. Can you post your real code? The copyFileToDirectory call is probably located in a try-catch block. Do you print or log any possible exceptions? Is your catch block empty? Do you have access to write to G:\ ?


1.G:\ is not an external hard disk, its local drive NTFS (disk management shrink for C:/ then create G:/)
2. Yes, I do print out exception , but there is no exception seen in the console app.
3. I tried running the program as Administrator, still same issue.

I can copy the file manually to the G:/.

 
Liutauras Vilda
Sheriff
Posts: 4928
334
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is by any chance you misplaced arguments other way round?
 
Liutauras Vilda
Sheriff
Posts: 4928
334
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
cle tan wrote:I can copy the file manually to the G:/.

Wait. But finally you are not copying to where you just wrote. You are trying to copy to particular directory mentioned in original post. Does that directory exist? If not, have you created it? Does it have permissions of writing?
 
cle tan
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Liutauras Vilda wrote:
cle tan wrote:I can copy the file manually to the G:/.

Wait. But finally you are not copying to where you just wrote. You are trying to copy to particular directory mentioned in original post. Does that directory exist? If not, have you created it? Does it have permissions of writing?

Yes the directory exist.

The full path of G: is something like this
G:/folder1/folder2/folder3

The current logon user is Administrator and it is a member of Administrators.

The folder itself for Administrator and Administrators have permissions for read/write

The parent folder permission has Administrators for read/write.
 
Liutauras Vilda
Sheriff
Posts: 4928
334
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So maybe just start showing your full code which is responsible for doing that job. Otherwise we just can guess what is happening there.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!