开发者

how to read a file from folder without giving filename , in objective c

开发者 https://www.devze.com 2023-02-08 23:59 出处:网络
I am moving a file to a folder ( file is stored in other folder), I am moving it by giving the file name, but I want to move all files, which r stored in a folder to some other folder.

I am moving a file to a folder ( file is stored in other folder), I am moving it by giving the file name, but I want to move all files, which r stored in a folder to some other folder.

How can I do this ?

Thanks in advance.

-(void)MoveFilesToMyInBoxFolder:(NSString *)destfileName

{

NSString* fullPath = [[NSBundle mainBundle] pathForResource:[destfileName stringByDeletingPathExtension]  ofType:@"xml"];

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

NSString *documentsDirectory = [paths objectAtIndex:0];

if (!documentsDirec开发者_JS百科tory) {
    NSLog(@"ERROR:Documents directory not found!");
    return;
}

i am calling this method like

[self MoveFilesToMyInBoxFolder:@"QS-H02032011100717AM1.xml"];


Using contentsOfDirectoryAtPath method of NSFileManager you can get an array of file names of all items within a directory. You can iterate through this array and move each item.

0

精彩评论

暂无评论...
验证码 换一张
取 消