File.delete() question.

Does anyone know what instances cause the method File.dete() to fail? Would simply having seperate File objects pointing at the same file path cause the delete to fail? If so is there any way around this or to overcome it? Thanks in advance.
Ross

Does anyone know what instances cause the method File.delete() to fail?The file doesn't exist, you don't have the necessary access level (at the OS level) to delete it, or you are on Windows and the file is currently open.
Would simply having seperate File objects pointing at the same file path cause the delete to fail?No.

Similar Messages

  • Newbie Muvo2 4GB File Deletion Question/Car Casse

    Hey Guys, Just got the Muvo2 Nomad from J&R. $40 after rebate. Anyway, I got it mainly to download MP3s of a radio broadcast. Each file is about 5MB in size, netting about 43 minutes of audio per file (@48k). At this rate, if my math is correct, the Muvo2 will hold approx 270 of these files before the 4GB dri've is full. How do you experienced Nomad users prefer deleting your files? Should I just let the dri've get completely full then delete, or delete the files every couple of weeks or so? Or split it down the middle?
    Also, do you guys have a favorite way of piping the Nomad's output into a car's cassette deck/AM/FM radio? I have seen the cassette adapters and the FM transmitters, and would like to know if one method is considered superior by experienced users. My car's AM/FM/Cassette is OEM from Nissan in 994, a bit long in the tooth and certainly not top of the line. Thanks in advance for any feedback... Clashrule

    As far as file management goes, I would say do whatever works for you. Do you archi've the shows?
    A cassette adapter is going to be better quality than an FM broadcaster. More on car connection here in the Zen FAQ at Nomadness.net (although it's for the Zen, it's equally applicable to the MuVo) http://www.nomadness.net/modules.php...+Jukebox+Zen#2

  • File deletion in root and subdirectories.

    Greetings,
    I have a question regarding Batch scripting. I am trying to create a system maintenancing script which removes .TMP and .BAK files from all of my drives both subdirectories and directories above. Let's say the Batch script would be placed into "Folder3"
    in the following internal drive address "C:\Folder1\Folder2\Folder3\Folder4\Folder5". And I want the batch script to remove files from folders 4 and 5 as subdirectories but also to remove files from C: Drive and folders 1, 2, and of course 3 itself
    but without removing folders. And I'd like to apply this method to all drives simultaneously without a human user personally moving the script via cut/copy and pasting from drive to drive. The other alternative which can come into consideration is to create
    a Batch File with any address location on the internal drive and when running this Batch file it'll create additional Batch Files on specified (multiple) drives at the very root of drives in the drive address of C:\ for instance, and initializes the required
    file deletion process. Some of the folders require my Administrator priviliges therefore I'd like to create a code within the script that ask for user permission and says "Yes" but without actually asking from me as the user to click "Ok"
    or "Yes" when running the script itself or to fully bypass the firewall. I have created the other part of the coding for deleting specified superfluous file types and in what way it's just the sub and above-directory part of it that gives me a pause
    to proceed. Any help is greatly welcome or pointers. If my request would seem cluttered please notify me of it and I'll try to simplify it down, although I hope I wasn't too confusing with the elaboration.
    Thank you in advance, even for the consideration.
    Kind Regards.

    @ECHO OFF
    for %%a in (C: D: E: F: G:) do call :Sub %%a
    goto :eof
    :Sub
    echo Processing %1
    del /s /q %1\*.tmp
    del /s /q %1\*.bak

  • File and question mark when starting

    Flashing file and question marl when i start my computer

    There are four general causes of this issue:
    1. The computer's PRAM no longer contains a valid startup disk setting when there aren't any problems with the disk itself. This can be checked for by pressing the Option key and seeing if the drive appears.
    2. The internal drive's directory structure has become damaged. This requires usage of an alternate bootable system to perform the repair.
    3. Critical system files have been deleted. This requires usage of an alternate bootable system to reinstall them.
    4. The internal drive has died or become unplugged. This is the most likely case if the computer took a sharp impact or there are unusual sounds coming from its location.
    (103563)

  • Adobe reader X 10.1.1 installer file deletes itself after installation starts?

    On my windows 7 pro 64bit, I downloaded the installer and installed adobe reader 10.1.1. Right after I started the installation the installer file disappeared. Did the installer file delete itself? Is this normal and as designed?
    The installer file name:
    install_reader10_en_air_gtbd_aih.exe

    The answer to the original poster's question is that this is normal and as designed.
    But *WHY* did Adobe design it this way?  It's simple enough to make a copy before doing the installation, but the first time it happens I have to stop and figure out if it's normal.
    I suppose there might be some benefit for the average naive user, but still, most installers don't have this behavior.

  • HT204053 best storage for filies deleted but used frequently wd drop box flash drive

    best storage for filies deleted but used frequently wd drop box flash drive

    Thanks LowLuster!  With that info I have another questions if that's ok.  First, I'm sure it's formatted to fat32.  I have learned I can't transfer movies over 4gb.  I use an external hard drive for those.  The files are ones I've downloaded from YouTube in the mp4 format and are never over 1gb.  They're all mb in size. 
    I didn't realize flash drives had limited writes.  Is there any way to confirm I've reached the limit?  Both times I reformatted it I was able to add back the videos I previously had on it.  I would say there were a hundred or so. Both times I left some "growing room" on the flash drive so I could add more files.  And, both times I was able to continuing adding until I had reached the max capacity.  The problem occured after I tried deleting files to free up space.  Does this make sense with "the amount you have used it" theory?  Does it start to become buggy at that point, or does it just make writes to the drive impossible?
    Thanks

  • Set permissions to prevent file deleting

    So, I have several iMacs that are basically public computers.  They will all access a shared server.  The machines need to possess all of the user permissions of a "read/write" user with the EXCEPTION of being allowed to delete.  As it is now, a random user could delete our entire server in two clicks.  So, I need to somehow secure our data while still allowing the "reading" and "editing" of files.
    •  Somehow disable the delete file function altogether (while still maintaining read/edit permissions)
    •  Find some 3rd party app or workaround that prompts the user with a password dialogue box in order to execute the "delete"
    •  Somehow apply permissions to a specific folder that enables read/edit, but disables file deleting
    Thoughts?

    You should post your question in this forum
    https://discussions.apple.com/community/servers_enterprise_software/os_x_server
    But in a nutshell, using ACL's, you can give people read-write access, but not give them full control (i.e they can't delete.).

  • Comitting File Deletions to Subversion Repository

    We use Subversion 1.6.9 with Dreamweaver CS6 to maintain version control on all our web site files.  I need to delete files in my local web site workspace and commit those deletions to the Subversion repository.  The instructions provided on the Adobe help pages don't seem to be in sync with the actual behavior of Dreamweaver CS6.
    I select the file I want to delete in the Files dialog (set to Local View) and press the Delete key on my keyboard.  The "Delete Subversion Assets" dialog appears.  I click the "Delete from Version Control" button.  In the Files dialog, a red minus sign appears to the left of the name of the file I deleted.  This all seems consistent with the available Adobe documentation.  I then right click the file name, select "Version Control" in the popup menu, then select "Commit" submenu item.  A dialog appears bearing the message, "Nothing to do for this operation."  Nevertheless, the file remains in the Subversion repository.
    Question:  What is the correct way to go about deleting a file locally in Dreamweaver and then commit that change to Subversion?

    Hi, Preran.
    Thanks for your response and link.  It appears CS4 had no support for Subversion file deletions.  I had hoped such support would have been added by the release of CS6.
    I may be forced to use a 3rd-party tool, e.g., TortoiseSVN, but wanted to avoid that course of action for fear of creating conflicts with Dreamweaver.
    If you receive additional information from your contacts, please post a reply.
    Many thanks,
    Mark (Amos_G)

  • Trying to delete file from trash but get this: The operation can't be completed because the item "File name" is in use. All other files delete except this one. Please help

    Trying to delete file from trash but get this: The operation can’t be completed because the item “File name” is in use. All other files delete except this one. Please help

    Maybe some help here:
    http://osxdaily.com/2012/07/19/force-empty-trash-in-mac-os-x-when-file-is-locked -or-in-use//

  • I got new hard driver for my MacBook I don't have the cd but I do have flash drive that has the software I need help because when I turn on my laptop it shows me a file with question mark how can I install the software from the flash driver?

    I got new hard driver for my MacBook I don't have the cd but I do have flash drive that has the software I need help because when I turn on my laptop it shows me a file with question mark how can I install the software from the flash driver?

    Hold down the Option key while you boot your Mac. Then, it should show you a selection of devices. Click your flash drive and it will boot from that.

  • HT2674 I have an iMac purchased in May 2011.  OSX Lion 10.7.3.  I deleted backup file from the external hard drive. Now, the trash can will not empty some of the files deleted.  File folder: "Core Services" contains a locked file: "boot.efi".  It will not

    I have an iMac purchased in May 2011.  OSX Lion 10.7.3.  I deleted backup file from the external hard drive which operates from Time Machine.
    Now, the trash can will not empty some of the files deleted from the backup harddrive.
    The trash contains-- File folder: "Core Services" which contains a locked file: "boot.efi". 
    It will not delete.
    How do I get the trash can empty of these files?

    Yes, the Old Master file has a folder for each year where I find all photos from that specific year. I am attaching a screen shot of the file.
    In the meantime i have managed to download all photos (it did not download any video files though in mpg, avi, 3gp, m4v,mp4 and mov format) to a new iphoto library. Unfortunately the photos are quite mixed and often doubled up. I ma considering to purchase iphoto library which checks all duplicates in iphoto. this will save me a lot of time. What do you think?

  • File.delete() and File.deleteOnExit() doesn't work consistently..

    I am seeing some odd behavior with trying to delete files that were opened. Usually just doing new File("file.txt").delete() would work. However, in this case, I have created an input stream to the file, read it in, saved it to another location (copied it), and now I am trying to delete it.
    The odd thing is, in my simple application, the user can work with one file at a time, but I move "processed" files to a lower pane in a swing app. When they exit it, it then archives all the files in that lower pane. Usually every file but the last one opened deletes. However, I have seen odd behavior where by some files don't delete, sometimes all of them wont delete. I tried the deleteOnExit() call which to me should be done by the JVM after it has released all objects such that they don't matter and the JVM ignores any object refs and directly makes a call (through JNI perhaps) to the underlying OS to delete the file. This doesn't work either.
    I am at a loss as to why sometimes some files delete, and other times they don't. In my processing code, I always close the input stream and set its variable to null. So I am not sure how it is possible a reference could still be held to the object representing the file on disk.

    and then, in the other class
      public int cdplayerINIToMMCD(File aDatabase, String thePassword) throws IllegalArgumentException {
         /*---------DATA---------*/
         String dbLogin, dbPassword;
         JFileChooser fc;
         INIFileFilter ff;
         int dialogReturnVal;
         String nameChosen;
         File INIFile;
         ProgressMonitor progressMonitor;
         BufferedReader inFileStream;
         String oneLine;
         int totalLines = 0;
         int linesParsed = 0;
         boolean openDBResult;
         int hasPassword;
         if ((aDatabase == null) || (!aDatabase.exists()) ||
            (FileManagement.verifyMMCD(aDatabase) == FileManagement.VERIFY_FAILED)) {
            throw new IllegalArgumentException();       
         else { 
            currentDB = aDatabase;
            if(thePassword == null) {
              dbPassword = "";
            else { dbPassword = thePassword; }
            dbLogin = dbPassword; //For MSAccess dbLogin == dbPassword
         //Ask the user for the cdplayer.ini file.
         //Create a file chooser
         if (System.getProperty("os.name").indexOf("Windows") > -1) {
            fc = new JFileChooser("C:\\Windows");
         else {
            fc = new JFileChooser();     
         fc.setMultiSelectionEnabled(false);
         fc.setDragEnabled(false);
         //Create a new FileFilter
         ff = new INIFileFilter();
         //Add this filter to our File chooser.
         fc.addChoosableFileFilter(ff);
         fc.setFileFilter(ff);
         //Ask the user to locate it.
         do {
            dialogReturnVal = fc.showOpenDialog(mainFrame);
            if (dialogReturnVal == JFileChooser.APPROVE_OPTION) {
               nameChosen = fc.getSelectedFile().getAbsolutePath();
               if(nameChosen.toLowerCase().endsWith(INIFileFilter.FILE_TYPE)) { INIFile=new File(nameChosen); }
               else { INIFile = new File(nameChosen+INIFileFilter.FILE_TYPE); }
               if (!INIFile.exists()) {
                  continue; //If the name specified does not exist, ask again.
               else { break; }
            else { //User clicked cancel in the open dialog.
               //Ignore what we've done so far.
               return(IMPORT_ABORTED);
         } while(true); //Keep asking until cancelled or a valid file is specified.
         //Determine how many lines will be parsed.
         try {
           //Open the INI for counting
           inFileStream = new BufferedReader(new InputStreamReader(new FileInputStream(INIFile)));
           while ((inFileStream.readLine()) != null) {
               totalLines++;
           //Close the INI file.
           inFileStream.close();
         } catch (IOException ex) { return(IMPORT_FAILED); }
         //Make a progress monitor that will show progress while importing.
         progressMonitor = new ProgressMonitor(mainFrame, "Importing file","", 0, totalLines);
         progressMonitor.setProgress(0);
         progressMonitor.setMillisToPopup(100);
         progressMonitor.setMillisToDecideToPopup(1);
         //Make our DatabaseHandler to insert results to the database.
         dbh = new DatabaseHandler();
         //Open the database connection.
         do {
           try {
              openDBResult = dbh.openDBConnection(currentDB, dbLogin, dbPassword);
           } catch(JDBCException ex) { return(IMPORT_JDBC_ERROR); } //OUCH! can't write anything.
             catch(SQLException ex) {
                 openDBResult = DatabaseHandler.OPNCN_FAILED;
                 //Can not open the database. Is it password protected?
                 hasPassword = JOptionPane.showConfirmDialog(mainFrame, "Could not open the database. "+
                                                "The password is wrong or you have not specified it.\n"+
                           "Do you want to enter one now?", "New password?", JOptionPane.YES_NO_OPTION);
                if (hasPassword == MMCDCatalog.DLG_OPTN_YES) {
                   dbPassword = JOptionPane.showInputDialog(mainFrame, "Please enter your "+
                                                              "password for the DataBase:");
                    dbLogin = dbPassword; //For MSAccess, login == password                                                    
                //If the password wasn't the problem, then we can't help it.
                else { return(IMPORT_FAILED); }
         } while(openDBResult != DatabaseHandler.OPNCN_OK); //If it is OK, no exception thrown.
         //Import the ini file
         try {
            //Open the INI file for parsing.
            inFileStream = new BufferedReader(new InputStreamReader(new FileInputStream(INIFile)));
            //Read and parse the INI file. Save entries once parsed.
            while ((oneLine = inFileStream.readLine()) != null) {
               parseLine(oneLine);
               linesParsed++;
               progressMonitor.setNote("Entries imported so far: "+entriesImported);
               progressMonitor.setProgress(linesParsed);
               if ((progressMonitor.isCanceled()) || (linesParsed == progressMonitor.getMaximum())) {
                  progressMonitor.close();
                  break;
            //Close the INI file.
            inFileStream.close();
         } catch (IOException ex) {
              //Make absolutely sure the progressMonitor has disappeared
                progressMonitor.close();
                if (dbh.closeDBConnection() != DatabaseHandler.CLSCN_OK) {
                 JOptionPane.showMessageDialog(mainFrame, "Error while reading the INI file.\n"+
                    "Error while attempting to close the database", "Error", JOptionPane.INFORMATION_MESSAGE);
              else {
                 JOptionPane.showMessageDialog(mainFrame, "Error while reading the INI file.",
                                                    "Error", JOptionPane.INFORMATION_MESSAGE);     
                return(IMPORT_FAILED);
         //Make absolutely sure the progressMonitor has disappeared
         progressMonitor.close();
         //Close the database connection
         if (dbh.closeDBConnection() != DatabaseHandler.CLSCN_OK) {
            JOptionPane.showMessageDialog(mainFrame, "Error while closing the database after import.",
                                          "Error", JOptionPane.INFORMATION_MESSAGE);
         //Did the user cancel?
         if (totalLines != linesParsed) {
            return(IMPORT_ABORTED);     
         //Success!
         //Everything ok. Return the number of entries imported.
         return(entriesImported);
      }

  • File.delete() not working properly

    Hi Forum!!
    I am trying with the below code :
    File file = new file("path");
    try{
    if(file.exists())
    System.+gc+();
    file.delete();
    System.+out+.println("Control in delete trx file after deletion"+ file.exists());
    }catch(SecurityException se){
    String msg= "Delete trx file if 3gttz file created : IO Problems";
    Log.+error+(msg, se);
    }file.exists() returns false But I when I check file, it still exhists with content 0 bytes .
    Is there a way to remove the entire file from the directory rather than deleting only the
    contents ? Need not to tell I did my initial search to solve the problem.
    Thanks
    Edited by: jagabandhu on Feb 10, 2009 1:09 PM

    georgemc wrote:
    PhHein wrote:
    corlettk wrote:
    We can't all be rocket surgeons, either ;-)Heart scientist is the word you're looking for.Or rockin' sturgeons. A (marginally) cooler - albeit fictional - alternative to this abominationFrom a crazy drunk:
    A "bottle in front of me" is better than a "frontal lobotomy"!
    (Sound out those two quoted strings.)

  • Okay, i have 2 bugs with maverick.  First, when I delete a file within a window, the files deletes but the preview doesn't delete until I close the window and reopen it.  Second, I work on a network of computers and the search feature is now buggy...

    Okay, i have 2 bugs with maverick.  First, when I delete a file within a window, the files deletes but the preview doesn't delete until I close the window and reopen it.  Second, I work on a network of computers and the search feature is now buggy...  When I search for a file, A) it asks me if it's a name, or it wont produce anything, and B), its slower than in prior OS versions and in some instances I have to toggle to a different directory and go back to my original directory in the search: menu bar or the search wont produce anything...  Very buggy. 

    It appears to me that network file access is buggy in Maverick.
    In my case I have a USB Drive attached to airport extreme (new model) and when I open folders on that drive they all appear empty. If I right click and I select get info after a few minutes! I get a list of the content.
    It makes impossible navigate a directory tree.
    File access has been trashed in Maverick.
    They have improved (read broken) Finder. I need to manage a way to downgrade to Lion again.

  • Java.io.File.delete worked in 1.1, 1.2, 1.3 & 1.4, but not in 5.0

    I have a logging utility I wrote originally in Java 1.0. A nightly housekeeping task runs which creates a ZIP file for the previous days log, then deletes the .log file. If I run this software with Java 5.0, the File.delete fails and the .LOG file remains on the disk. No exceptions are thrown. delete just returns false.
    Any ideas?

    to find a bug this basic! Each day I switch to a new log file, leaving the previous days file. I was never closing the old PrintStream... Jees... How embarrassing.

Maybe you are looking for

  • Need help in use of application item - value to be changed dynamically

    HI , i have created a application item and i want to change the value of the application item when user link the URL link for eg- I have two link - htp.p('<tr><td>AABB<td>'); (a href="f?p=&APP_ID.:6:&SESSION..:F129_DB_NM:XXXXX">page 1) htp.p('</a></t

  • RFC via XI - SOAP-Adapter

    Hallo, Hi, I have configured RFC-Sender and  SOAP receiver adapter. RFC-Sender has the entry for Applicationserver and Programmid. Programmid is unique on our system. On testing in R/3, execute z_bapixx with created destination (TCP/IP), I get a runt

  • TV shows and podcast for Zen microph

    My son had to get the Zen microphoto. He couldn't be like my girls and get the apple photo. He claims Zen is so much better. How /where do I go to get tv shows and 'video' podcast for the microphoto The girls have tons in their itunes account. I gues

  • Glossary of components used in SNC

    Hi, I am new to SNC and to understand it better I need the Glossary of various components used in SNC. For eg Transportation Lane: A transportation lane connects the ship-from location with the customer location. You must assign the product that the

  • MRP scheduling at the back ground??

    hii Can somebody explain me how to set MRP to be scheduled at the back ground. Step by steps activities for this  and if any ABAPer help we have to get , mention that also. Thanks