Solved

Correct Path not being Passed

Posted on 2006-11-10
8
145 Views
Last Modified: 2010-03-31
I am trying to copy a file from one location to another but my file path seems to be getting "changed" on the way.

I start off with: ThreadProcessFiles processThread = new ThreadProcessFiles(new File(fileList[0]).getAbsolutePath());

But the output in the called class looks like: C:\Documents and Settings\username\workspace\ProjectTestImage-001.tif

Which property should I be passing to have the correct link to the file in the Windows platform?

0
Comment
Question by:lasutton
  • 4
  • 2
  • 2
8 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 17916635
>>But the output in the called class looks like: C:\Documents and Settings\username\workspace\ProjectTestImage-001.tif

What is wrong with that and why?
0
 

Author Comment

by:lasutton
ID: 17916648
The actual location of the original file is C:\Input\TestImage-001.gif.

0
 

Author Comment

by:lasutton
ID: 17917204
My problem was as follows:

When using a ".list" of a directory, the string does not contain the path of the files created.  As the path returns a "null" value the .get..Path.. values return the directory of the running application.  

So the directory name needs to be prefixed to the file name found.

                  File foundFile = new File(directoryToMonitor + File.separatorChar + fileList[0] );
0
 
LVL 92

Expert Comment

by:objects
ID: 17918058
>                File foundFile = new File(directoryToMonitor + File.separatorChar + fileList[0] );

could also be done using:

File dir = new File(directoryToMonitor);

               File foundFile = new File(dir, fileList[0] );
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 86

Accepted Solution

by:
CEHJ earned 500 total points
ID: 17918848
>>the .get..Path.. values return the directory of the running application.  

You'll find it's not that directory but the one from where it's being run
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 17930211
:-)
0
 
LVL 92

Expert Comment

by:objects
ID: 17936733
> You'll find it's not that directory but the one from where it's being run

the directory of the running appication *is* the directory where it is being run from :-D
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 17936744
?
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
groupNoAdj 7 86
github account with ecipse 1 42
JavaScript/Java - Changing an image background color 4 56
Error trying to install RTMT Win7 5 41
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This video teaches viewers about errors in exception handling.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now