hi all there !
I have problem with java file object that when ever i want to delete a file from the server i have check whether its exist or not for this i get fileObject.getAbsolute path but it return me wrong path but i get path from db a give to file object although it give to error no file exist
my code the below
Thanks to in advance if not mind ?
<%
// out.println("B4 try sk");
ResultSet rst=null;
ArrayList imgPath=new ArrayList();
ArrayList imgNam=new ArrayList();
//cUser is current user who log on to system
try{
String query ="Select * from imageinfo where userName like'%" + cUser +"%'";
rst=db.ExecuteQuery(query);
}
int count=1;
while(rst.next())
{
imgPath.add(rst.getString("imagePath"));
imgNam.add(rst.getString("imgName"));
count++;
}//end while loop
String usrid=session.getAttribute("usr").toString();
String serverFolder="D:\\";
String imgID=request.getParameter("p1");
String usrID=null;
String location1=null;
for(int ii=0;ii<imgPath.size();ii++)
{
// usrID="\\"+usrid+"\\"+"\\"+imgFold.get(ii).toString()+"\\";
location1= imgPath.get(ii).toString()+"\\"+imgNam.get(ii).toString();
File fi=new File(location1);
//out.println("Cononical Path \t"+fi.getCanonicalPath());
// File newfile=new File(fi.getCanonicalPath());
out.println("Cononical Path \t"+fi.getPath());
if(fi.exists())
{
boolean success;
out.println("SuccessFull");
// String fipath=fi.getAbsolutePath();
success= fi.delete();
out.println(success);
}
else
{
out.println(" file at \t"+location1+"\t does not exist");
}
}
out put it generated is "Cononical Path C:\Documents and Settings\shahbaz\jbproject\skpiat1\Tomcat\ D:\shahbaz\Family \Eyes.jpg "
But actual path is "Path from db is D:\shahbaz\Family \Eyes.jpg "
plz plz get me out of this horrible daemon