BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 06-08-2007, 03:01 PM   #1 (permalink)
New Member
 
Join Date: Jun 2007
Model: Pearl
PIN: N/A
Carrier: The new ATandT
Posts: 4
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default FileConnection delete() problem

Please Login to Remove!

I'm getting an IOException of "File system error" using FileConnection.delete() SOMETIMES when I try to delete a file even though FileConnection.exists() says it exists. I've looked at the docs and tried several things, but I'm still getting the error. Here are my exists() and delete() functions:

Code:
// I call these functions like this:

if (exists(filename))
       delete(filename);  // BAM!....IOException!!

        public static boolean exists(String qualifiedName) {
            boolean ret = false;
            String parsedQualifiedName = translateFilenameToRIM( qualifiedName );
            try {
                defaultDrive = pickADrive();
                FileConnection fconn = (FileConnection) Connector.open("file:///" + defaultDrive + parsedQualifiedName ); 
                ret = fconn.exists();  
                fconn.close();
            }
            catch (IOException ioe)
            {
            }
            return ret;
        }

  
        public static boolean delete(String name) {
            boolean ret = false;
            String parsedName = translateFilenameToRIM( name );
            try {
                defaultDrive = pickADrive();
                FileConnection fconn = (FileConnection) Connector.open("file:///" + defaultDrive + parsedName ); 
                if (fconn.exists())
                {
                    fconn.delete(); 
                } 
                fconn.close();
                ret = true;
            }
            catch (IOException ioe)
            {
                RimLogger.logErr("F Failed delete file: " + parsedName + " " + ioe.getMessage());  
            }
            return ret;
        }


Has anyone else seen this or can offer suggestions?

Thanks,

Ferrol Blackmon
Offline  
Old 06-10-2007, 11:56 PM   #2 (permalink)
Knows Where the Search Button Is
 
Join Date: Feb 2007
Location: India
Model: 7100v
Carrier: aittel
Posts: 35
Post Thanks: 0
Thanked 0 Times in 0 Posts
Post

Hi Ferrol,
try this code
Code:
FileConnection fconn = (FileConnection) Connector.open("file:///" + defaultDrive + parsedQualifiedName ); 
if (fconn.exists())
    fconn.delete();
Offline  
Old 06-11-2007, 04:01 AM   #3 (permalink)
CrackBerry Addict
 
Join Date: Jun 2005
Location: Manchester, UK
Model: BOLD
Carrier: t-mobile
Posts: 714
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

er, he's already doing it like that in his delete method.

does it fail with different files? or is the bug happening on the same filename? my first thought would be to check for differences in the filenames, or does your translateFilenameToRIM() method fail and return null?
__________________
new job doesn't allow a public profile - please do not contact this user with questions, you will not get a response. good luck!
Offline  
Old 06-11-2007, 08:24 AM   #4 (permalink)
New Member
 
Join Date: Jun 2007
Model: Pearl
PIN: N/A
Carrier: The new ATandT
Posts: 4
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

I've checked the filenames and they are the same. The translateFilenameToRIM() function returns a valid string.

One thing that may be noteworthy is that the filename is "H^_testfile1.txt".

Does that seem ok?

Thanks,

Ferrol Blackmon
Offline  
Old 06-11-2007, 10:06 AM   #5 (permalink)
CrackBerry Addict
 
Join Date: Jun 2005
Location: Manchester, UK
Model: BOLD
Carrier: t-mobile
Posts: 714
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

strange it's intermittent if the filenames are the same but try it with a filename without any strange characters in (ie: ^)
__________________
new job doesn't allow a public profile - please do not contact this user with questions, you will not get a response. good luck!
Offline  
Old 06-13-2007, 12:16 AM   #6 (permalink)
Thumbs Must Hurt
 
Rose's Avatar
 
Join Date: Nov 2006
Location: India
Model: 9700
OS: Windows 7
Carrier: Airtel
Posts: 121
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,
I dont think so it is due to the filename .. Bcoz if anything wrong with the filename it will throw an exception during a file connection itself and comes out.
It wont return fileexists == true. Check whether the fileConnection is a file or directory.
If it is directory means you can delete it if it is empty only.
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.