我有应用程序,我已经录制了声音文件,我希望我可以检查,如果我需要或现有的文件应该上传到服务器其他明智不
我有类型数组,其中有像重要等的值我想要如果这个文件退出我有[自上传]的方法然后它应该被调用,否则不是
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];
}
答案 0 :(得分: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");
}
}
答案 1 :(得分:0)
与上面的答案非常相似,但为了完整起见,根据您的问题,您的代码应该是什么样子。 (我猜你对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");
}