473,320 Members | 1,879 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

File.delete returns false.

dmjpro
2,476 2GB
Expand|Select|Wrap|Line Numbers
  1. File l_file = new File(path);
  2. System.out.println(l_file.exists()); //returns true
  3. System.out.println(l_file.delete()); //returns false
  4.  
How does this happen? Could anyone explain?
Sep 14 '10 #1
5 9738
jkmyoung
2,057 Expert 2GB
Do you have permissions to delete the file? Someone else may have the file open.
Sep 14 '10 #2
dmjpro
2,476 2GB
Then i think program would have an security exception or IO exception.Is not it?
Sep 15 '10 #3
Dheeraj Joshi
1,123 Expert 1GB
Is this file being used by somebody else or some other processes?

Regards
Dheeraj Joshi
Sep 15 '10 #4
dmjpro
2,476 2GB
Ok. tell me one thing when File.deleted throws Exception and when returns false?
Sep 15 '10 #5
jkmyoung
2,057 Expert 2GB
It could also be that the path you are pointing to is a non-empty directory.

I 'think' you only get a SecurityException if you don't have permissions to delete the file, but just false for most other situations.
Sep 17 '10 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Martin Lucas-Smith | last post by:
I wrote the function below as part of a larger class. The fopen stage works, and, as according to the documentation at www.php.net/fopen that succesfully creates a new file. The fwrite stage...
3
by: annie | last post by:
Hi I've got two linux boxes running redhat9 and either PHP Version 4.2.2 or PHP Version 4.3.7. The file structure is set up the same on both machines and both files exist. The problem is not...
5
by: lkrubner | last post by:
www.php.net says: >>>>>>>>>>>> Only for SELECT,SHOW,EXPLAIN or DESCRIBE statements mysql_query() returns a resource identifier or FALSE if the query was not executed correctly. For other type of...
12
by: Lucas Tam | last post by:
I have a very simple loop: If (Directory.Exists(tempDirectory)) Then Try Dim Files() As String = Directory.GetFiles(tempDirectory) 'Clear out directory For Each Filename As String In Files...
6
by: Kimmo Laine | last post by:
Running IIS 6 on Windows 2003 server. After an update to the most recent version of php 5.1.2, for some reacon a function handling uploaded files using is_file stopped working. is_file failed...
3
by: peter | last post by:
I have a weird problem in some code I am writing. The user selects a number of files from a list and then can select an option which will rename the selected files. Before the process starts, a...
4
by: Italian Pete | last post by:
Hi, I have a website sitting on a server (ServerA) with images to be displayed sitting on a separate server (ServerB) on the same network. I am trying to test for the existance of an image...
0
by: tjonsek | last post by:
I am working with directories in PHP for the first time. I have code that I've changed multiple times to try different things. I would think this is pretty standard fare so I'm not sure why I can't...
12
by: snow | last post by:
Hi All, I noticed if file path has a white space, for example "C:\my document \test.txt", the function File.Exists(filePath) always return false in release mode. How could I make this function...
1
by: Samuel R. Neff | last post by:
I have a file in a directory that is returned from Directory.GetFiles() but subsequently fails a File.Exists() check. Test code: string p = @"C:\documents and settings\all users\" +...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.