如何在目标c中从文件夹中读取文件而不给出文件名
我正在将文件移动到文件夹(文件存储在其他文件夹中),我通过给出文件名来移动它,但我想将存储在文件夹中的所有文件移动到其他文件夹。
我该怎么做?
提前致谢。
-(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 (!documentsDirectory) {
NSLog(@"ERROR:Documents directory not found!");
return;
}
我这样称呼这个方法
[self MoveFilesToMyInBoxFolder:@"QS-H02032011100717AM1.xml"];
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 (!documentsDirectory) {
NSLog(@"ERROR:Documents directory not found!");
return;
}
i am calling this method like
[self MoveFilesToMyInBoxFolder:@"QS-H02032011100717AM1.xml"];
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 NSFileManager 的 contentsOfDirectoryAtPath 方法,您可以获得目录中所有项目的文件名数组。您可以迭代该数组并移动每个项目。
Using
contentsOfDirectoryAtPath
method ofNSFileManager
you can get an array of file names of all items within a directory. You can iterate through this array and move each item.