因此,我可以删除图像缓存,但有没有办法删除应用程序存储中的文件?例如,如果您转到设置>常规>存储和iCloud使用>管理存储,然后找到您的应用程序。我想清除这些数据,因为它不断增加。对此有何看法?清除ios应用程序存储数据?
这是我目前有:
var documents = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
var cache = System.IO.Path.Combine(documents, ".config", ".isolated-storage", "ImageLoaderCache");
foreach (var file in System.IO.Directory.GetFiles(cache))
{
//older than or 3 days, delete
DateTime fileCreationDate = System.IO.File.GetCreationTime(file);
if ((DateTime.Now - fileCreationDate).Days >= 3)
{
System.IO.File.Delete(file);
}
}
我想你正在寻找'NSCachesDirectory'而不是'MyDocuments':http://stackoverflow.com/questions/15064854/delete-files-from-nscachesdirectory-programmatically – SushiHangover