Example #1
0
 /// <summary>
 /// Loads the cache for a view of a folder when we need it.
 /// </summary>
 /// <param name="dir"></param>
 /// <returns></returns>
 private List <FileShortInfo> getCachedFiles(DirectoryCacheInfo dir)
 {
     if (dir.fileCount == 0)
     {
         return(new List <FileShortInfo>());
     }
     else
     {
         //load cache
         try
         {
             FileCacheInfo tempFiles     = new FileCacheInfo();
             string        cacheFilePath = cacheDirectory + "\\" + dir.Guid.ToString();
             using (StreamReader stream = new StreamReader(cacheFilePath, Encoding.UTF8))
             {
                 tempFiles = (FileCacheInfo)xmlSer.Deserialize(stream);
             }
             return(tempFiles.files);
         }
         catch (Exception e)
         {
             throw new Exception("Error reading a set of cache info", e);
         }
     }
 }
Example #2
0
        /// <summary>
        /// Remove an item from the cache
        /// </summary>
        /// <param name="path"></param>
        public void removeCacheData(String path)
        {
            DirectoryCacheInfo existing = null;

            foreach (DirectoryCacheInfo di in theCache)
            {
                if (di.path == path)
                {
                    existing = di;
                }
            }
            theCache.Remove(existing);
        }
Example #3
0
        /// <summary>
        /// Loads the cache for a view of a folder when we need it. 
        /// </summary>
        /// <param name="dir"></param>
        /// <returns></returns>
        private List<FileShortInfo> getCachedFiles(DirectoryCacheInfo dir)
        {
            if (dir.fileCount == 0) { return new List<FileShortInfo>(); }
            else
            {

                //load cache
                try
                {

                    FileCacheInfo tempFiles = new FileCacheInfo();
                    string cacheFilePath = cacheDirectory + "\\" + dir.Guid.ToString();
                    using (StreamReader stream = new StreamReader(cacheFilePath, Encoding.UTF8))
                    {
                        tempFiles = (FileCacheInfo)xmlSer.Deserialize(stream);
                    }
                    return tempFiles.files;
                }
                catch (Exception e)
                {
                    throw new Exception("Error reading a set of cache info", e);
                }
            }
        }