sancheese
sancheese

Reputation: 332

Error while deleting the file

While deleting existing the file with this command:

[[NSFileManager defaultManager] removeItemAtPath:self.sourceFileName error:&error];

I got the following error

Error: ImageIO: CGImageReadCreateDataWithMappedFile 'open' failed '/Users/asdasd/Library/Application Support/iPhone Simulator/7.1/Applications/DD251D7D-F0AF-40E1-A033-F221623D589D/Library/ScanSession/Source/page3.jpeg error = 2 (No such file or directory)'

This happens while I copied pic from album into app folder. The most interesting thing is that file exists, but not fully copied. Is there a way to check wether file is file operation completed?

Upvotes: 1

Views: 1222

Answers (3)

sancheese
sancheese

Reputation: 332

Solved it 2 yars ago. Forgot to post & close the question. It was caused by another thread, where the file was deleted first. I think its one of the standart mutlithreading issues while working with CoreData

Upvotes: 0

John Bushnell
John Bushnell

Reputation: 1871

I have a similar problem right now, and it seems as though when you delete a file that certain other methods you may have called immediately prior may actually not have completed yet. I'm considering delaying the actual deletion of files to allow for background processes to complete.

Upvotes: 0

codercat
codercat

Reputation: 23271

check weather your file & Directory available

   for (NSString *filename in files) {
    NSString *path = [yourPath stringByAppendingPathComponent:yourFileName];        
    BOOL isDir;
    if([[NSFileManager defaultManager] fileExistsAtPath:yourPath isDirectory:&isAvilDir] && isAvilDir){
        NSLog(@"%@ Check is a directory", your path file);  
    }
    else {
        NSLog (@"%@ Check is a file",your path file);
    }
}

Upvotes: 1

Related Questions