itunes文件共享恢复已删除的文件

时间:2021-02-26 23:00:36

My app uses iTunes File Share. I used the code to delete a single file: It worked the first time. On the second try, however, iTunes showed a empty share directory. It turns out all data files are gone. Can I recover those data files from the iPad? Thanks

我的应用使用iTunes文件共享。我使用代码删除单个文件:它第一次工作。然而,在第二次尝试时,iTunes显示了一个空的共享目录。事实证明,所有数据文件都已消失。我可以从iPad恢复这些数据文件吗?谢谢

- (void) deleteFileFromDisk: (NSString*) fileName {
  if([self fileExists: fileName])  {
        NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) ;
        NSString *documentsDirectory = [paths objectAtIndex: 0];
        NSString* theFile = [documentsDirectory stringByAppendingPathComponent: fileName];
        NSError *error;
        [[NSFileManager defaultManager] removeItemAtPath: theFile error: &error];

1 个解决方案

#1


There's no "restore" feature on the iPad. But in all probability there's nothing to worry about.

iPad上没有“恢复”功能。但很可能没有什么可担心的。

There's nothing about your code that would delete multiple files. It would delete just that file from the Documents directory that you supplied the name of as fileName. If you didn't call deleteFileFromDisk: multiple times, you didn't delete multiple files.

您的代码没有任何内容可以删除多个文件。它将仅从您提供名称为fileName的Documents目录中删除该文件。如果您没有多次调用deleteFileFromDisk:您没有删除多个文件。

Perhaps at some point you deleted the app. That would delete its entire sandbox and thus would take with it anything in the Documents directory. That sort of thing is perfectly normal during repeated testing.

也许在某些时候你删除了应用程序。这会删除整个沙箱,因此会在Documents目录中使用它。在重复测试期间,这种事情是完全正常的。

#1


There's no "restore" feature on the iPad. But in all probability there's nothing to worry about.

iPad上没有“恢复”功能。但很可能没有什么可担心的。

There's nothing about your code that would delete multiple files. It would delete just that file from the Documents directory that you supplied the name of as fileName. If you didn't call deleteFileFromDisk: multiple times, you didn't delete multiple files.

您的代码没有任何内容可以删除多个文件。它将仅从您提供名称为fileName的Documents目录中删除该文件。如果您没有多次调用deleteFileFromDisk:您没有删除多个文件。

Perhaps at some point you deleted the app. That would delete its entire sandbox and thus would take with it anything in the Documents directory. That sort of thing is perfectly normal during repeated testing.

也许在某些时候你删除了应用程序。这会删除整个沙箱,因此会在Documents目录中使用它。在重复测试期间,这种事情是完全正常的。