Hello, > -----Ursprüngliche Nachricht----- > Von: Anne Milbert [mailto:[EMAIL PROTECTED] > Gesendet: Mittwoch, 7. Dezember 2005 17:13 > An: Tomcat Users List > Betreff: Howto delete a file with a servlet??? > > Hi anyone, > > I'd like to delete a file with a servlet. I tried it with the > delete() function and with the runtime.exec() function. What > am I doing wrong? > > Here's my code: > Solution 1: > [...] > String cmd = "del C:\\" + request.getParameter("Id") + "-" + > eleno + ".xml"; Runtime runtime = Runtime.getRuntime(); > Process process = runtime.exec(datname) [...] > > Solution 2: > [...] > String datname = "C:\\" + request.getParameter("Id") + "-" + > eleno + ".xml"; boolean success = (new > File("datname")).delete(); if (!success) { > out.println("Couldn't delete file: " + datname); } [...]
- Try '(new File(datname)).delete()'. - If that does not work check if the value of datname is correct. - If it is check if you can delete the file manually. If not than that file has been opened from your application and can't be deleted til closed on a windows system (linux does not care about these things). - If that does not help too, check if the user account tomcat is running under is allowed to delete that file (see security tab). Bjoern Eickvonder > Regards, > Anne > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]