I have a simple jave program as below:
package us.ma.main;
import java.io.File;
public class DeleteFile {
public static void main(String[] args) {
String fileName = "c:/Barcode/BarcodeSeqence.txt";
File file = new File( fileName );
if( file.exists()){
file.delete();
System.out.println( fileName + " deleted." );
}
else{
System.out.println( fileName + " not found." );
}
}
}
The program is called by another application using the following command line (enclosed by #):
#java -Xms64m -Xmx512m -classpath ".;c:\barcode\ResetSequenceNumber.jar" us.ma.main.DeleteFile#
It worked fine on WIndows XP and Windows 2000 until the code was moved to Windows 2003 server. The calling application gives me this error message: "The system can not find the file specified". I add the following debug code and running on Windows 2003 server:
String user = System.getProperty("user.name");
System.out.println( "userName: " + user );
if( file.canRead()){
System.out.println( "Has read access" );
}
else{
System.out.println( "Can not read the file" );
}
if(file.canWrite()){
System.out.println( "Has write access" );
}
else{
System.out.println( "Can not write to the file" );
}
I found out that file.exists() returns false,
both if( file.canRead()) and if( file.canWrite())
return false even though the file is physically exist and the file is owned by Administrator.
Can anyone please advice?
I started this thread earlier, it seemed not posted successfully. Here I am trying it again.
Thanks.
Ling
package us.ma.main;
import java.io.File;
public class DeleteFile {
public static void main(String[] args) {
String fileName = "c:/Barcode/BarcodeSeqence.txt";
File file = new File( fileName );
if( file.exists()){
file.delete();
System.out.println( fileName + " deleted." );
}
else{
System.out.println( fileName + " not found." );
}
}
}
The program is called by another application using the following command line (enclosed by #):
#java -Xms64m -Xmx512m -classpath ".;c:\barcode\ResetSequenceNumber.jar" us.ma.main.DeleteFile#
It worked fine on WIndows XP and Windows 2000 until the code was moved to Windows 2003 server. The calling application gives me this error message: "The system can not find the file specified". I add the following debug code and running on Windows 2003 server:
String user = System.getProperty("user.name");
System.out.println( "userName: " + user );
if( file.canRead()){
System.out.println( "Has read access" );
}
else{
System.out.println( "Can not read the file" );
}
if(file.canWrite()){
System.out.println( "Has write access" );
}
else{
System.out.println( "Can not write to the file" );
}
I found out that file.exists() returns false,
both if( file.canRead()) and if( file.canWrite())
return false even though the file is physically exist and the file is owned by Administrator.
Can anyone please advice?
I started this thread earlier, it seemed not posted successfully. Here I am trying it again.
Thanks.
Ling