Results 1 to 7 of 7
Thread: About File handle...
- 07-13-2010, 07:12 AM #1
Member
- Join Date
- Jun 2010
- Posts
- 17
- Rep Power
- 0
About File handle...
Hello Friends...
I am trying to delete a file using some code. But it's not getting deleted
with delete() function of 'File' class. I had been told that it might be
getting used by some other program. So Please tell me is there anyway
we can check whether the file is being used by some other program or not?
Thanks. Bye... :)
- 07-13-2010, 09:06 AM #2
Member
- Join Date
- Jul 2010
- Location
- India, Mumbai
- Posts
- 5
- Rep Power
- 0
will you plz send me code snippet,
why don't u try something like this.
File file = new File("c:\\abc.txt");
if(file. exists())
{
file.delete();
}
......(SINGH IS KING):)
- 07-13-2010, 09:39 AM #3
Because that is nonsense.
Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
The Ubiquitous Newbie Tips
- 07-13-2010, 01:53 PM #4
Member
- Join Date
- Jun 2010
- Posts
- 17
- Rep Power
- 0
- 07-14-2010, 09:21 AM #5
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Presumably if delete() returns false then you can assume that either the user doesn't have permission to delete the file, or the file is in use. So check that flag and inform the user if it comes back false..."Cannot delete file blah. Either it is in use or you do not have sufficient privileges."
Something like that.
- 07-14-2010, 07:04 PM #6
Senior Member
- Join Date
- Mar 2009
- Posts
- 552
- Rep Power
- 5
Do you have FileOutput/InputStreams open to the file you try to delete? That could be causing your problem as well... make sure you call the close() method on any FileXXXStream you use.
If the above doesn't make sense to you, ignore it, but remember it - might be useful!
And if you just randomly taught yourself to program, well... you're just like me!
- 07-19-2010, 07:28 AM #7
Member
- Join Date
- Jun 2010
- Posts
- 17
- Rep Power
- 0
Similar Threads
-
Handle sound
By varsamakos in forum AWT / SwingReplies: 4Last Post: 12-26-2009, 09:40 PM -
how to handle files?
By sayan751 in forum Advanced JavaReplies: 5Last Post: 06-10-2009, 08:39 PM -
handle FileNotFoundException
By minifish in forum New To JavaReplies: 13Last Post: 11-08-2008, 02:01 AM -
[SOLVED] reader and writer on same file handle
By Nicholas Jordan in forum Advanced JavaReplies: 11Last Post: 07-01-2008, 03:39 AM -
Better way to handle exceptions
By javaplus in forum Advanced JavaReplies: 2Last Post: 01-16-2008, 06:47 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks