Login  Register

Re: File.Delete - temp folder?

Posted by Michael Schmid on Sep 08, 2008; 8:40am
URL: http://imagej.273.s1.nabble.com/File-Delete-temp-folder-tp3695147p3695148.html

Hi Robert,

As written in the documentation, for deleting the file must be
in one of these
  - (1) in the user's home directory
  - (2) the ImageJ directory or
  - (3) the temp directory.

Actually, any directory with "ImageJ" in the path will fulfil
(2), so you can delete, e.g. /disk2/data/ImageJdata/myimage.tiff

The temp directory for (3) is the one you get with
getDirectory("temp").

To avoid the "1" in the log Window, assign the result to a
variable:
   success = File.delete(myPath+myFilename);
or
   if (!File.delete(myPath+myFilename)) exit("Delete failed");

Michael
________________________________________________________________

On 4 Sep 2008, at 20:57, Robert Barton wrote:

> Hi all,
>
> I am trying to incorporate the file.delete function into a macro  
> and am
> able to get it to work if I use an "ImageJ" directory somewhere  
> along the
> path, but it will not work if I use a "temp" folder.  I have
> tried "temp", "tmp", "Temp", and "Tmp" with no luck.
>
> It is not imperitive to change it, but would make my files less  
> confusing
> for someone else who may be using them.
>
> Also, is it possible to bypass the "1" that signifies that the file  
> was
> deleted?
>
> Thanks