因此,我可以刪除圖像緩存,但有沒有辦法刪除應用程序存儲中的文件?例如,如果您轉到設置>常規>存儲和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