| Author |
File Delete problem
|
imran ghani
Greenhorn
Joined: Dec 20, 2002
Posts: 1
|
|
i m trying to delete a file through my servlet using the following code. File file1 = new File(s); boolean flag1 = file1.delete(); if(!flag1){ printwriter.println("Can't Delete " + s + " <br>"); return "false"; } printwriter.println("deleted Successfully <br>"); s is a string variable containing path s = "img/20-December-2002/101_heading.gif" Alway's give me message can't delete file.Although file exists at this path. Please give some solution... Imran Ghani.
|
 |
William Brogden
Author and all-around good cowpoke
Rancher
Joined: Mar 22, 2000
Posts: 12271
|
|
The way you have expressed the path without a root implies that it is relative to the "current" directory, but in a servlet you have no control over the current directory. Bill
|
Java Resources at www.wbrogden.com
|
 |
Michael Bronshteyn
Ranch Hand
Joined: Mar 26, 2002
Posts: 85
|
|
|
make sure the user who runs servlet container has permission to delete the file ( write permission ).
|
Michael
SCJP2
|
 |
Malhar Barai
Author
Ranch Hand
Joined: Aug 17, 2001
Posts: 399
|
|
hi dear i go with michael, check for the "Permission", i do create a lot of problem if not set properly.
|
Malhar Barai
SOA & Java Book
|
 |
 |
|
|
subject: File Delete problem
|
|
|