0

I have app in which i have recorded sound files i want that i may check that if files which i need or existing it should upload to server other wise not

I have type array in which there values like vital etc i want that if this file exits i have method like [self upload] then that it should be called otherwise not

    int i=0;
    for (i=0; i<[types count]; i++) {


    NSString*type=[types objectAtIndex:i];

   NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
   NSString *documentsDirectory = [paths objectAtIndex:0]; 




   NSString * filePath = [NSString stringWithFormat:@"%@/Documents/%@_%@_%@_%@.wav", NSHomeDirectory(),theCellData.firstName,theCellData.lasttName,theCellData.patientId,type];




  BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:filePath];

   }

2 Answers2

0
int i=0;
for (i=0; i<[types count]; i++) 
{
NSString*type=[types objectAtIndex:i];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];  
NSString *filePath = [NSString stringWithFormat:@"%@/%@_%@_%@_%@.wav",documentsDirectory,theCellData.firstName,theCellData.lasttName,theCellData.patientId,type];
 BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:filePath];
if (fileExists == 0) 
{
    NSLog(@"File is Not exists");
}
else
{
   NSLog(@"File exists");
 }
}
Ravi Kumar Karunanithi
  • 2,151
  • 2
  • 19
  • 41
0

Much like the answer above, but for completeness, what your code should look like, based on your question. (I'm guessing you're somewhat new to Cocoa...)

NSString* documentsPath1 = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString* foofile = [documentsPath1 stringByAppendingFormat:@"/%@_%@_%@_%@.wav", theCellData.firstName, theCellData.lasttName, theCellData.patientId, type];
BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath: foofile];
if (fileExists == NO) 
{
     NSLog(@"File does not exist");
}
else
{
     NSLog(@"File exists");
}
horseshoe7
  • 2,745
  • 2
  • 35
  • 49