示例#1
0
        public static bool FileIsExpired(IsolatedStorageFile isolatedStorage, string imageFileName, int cacheDays)
        {
            // Very very very ugly function to determine lastwritetime of file in isolated storage
            if (cacheDays == 0)
                return false;

            try
            {
                var propertyInfo = isolatedStorage.GetType().GetField("m_RootDir",
                                                                      BindingFlags.NonPublic | BindingFlags.Instance);
                if (propertyInfo != null)
                {
                    var rootDir = propertyInfo.GetValue(isolatedStorage) as string;
                    if (rootDir != null)
                    {
                        var file = new FileInfo(rootDir + imageFileName);
                        if (file.Exists)
                        {
                            if (file.LastWriteTime < DateTime.Now.AddDays(-cacheDays))
                                return true;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
            return false;
        }
        private static string GetFullyQualifiedFileName(string path, IsolatedStorageFile store)
        {
            var fieldInfo = store.GetType()
                                 .GetField(ISOLATED_STORE_ROOT_DIR,
                                           System.Reflection.BindingFlags.NonPublic |
                                           System.Reflection.BindingFlags.Instance);
            if (fieldInfo != null)
            {
                return Path.Combine(fieldInfo.GetValue(store).ToString(), path);
            }

            return "";
        }
 private static string GetFullyQualifiedFileName(string path, IsolatedStorageFile store)
 {
     return Path.Combine(store.GetType().GetField(IsolatedStorageFileSystem.IsolatedStoreRootDir, System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).GetValue(store).ToString(), path);
 }
 private static string RootDirectoryGet(IsolatedStorageFile isolatedStorage)
 {
     FieldInfo  fi= isolatedStorage.GetType().GetField("m_RootDir",
         System.Reflection.BindingFlags.Instance |
         System.Reflection.BindingFlags.NonPublic |
         System.Reflection.BindingFlags.Static);
     string m_RootDir = fi.GetValue(isolatedStorage).ToString();
     return m_RootDir;
 }