GetFileNames() public method

public GetFileNames ( ) : string[]
return string[]
Exemplo n.º 1
0
        private static void GetFiles(string dir, string pattern, IsolatedStorageFile storeFile)
        {
            string fileString = System.IO.Path.GetFileName(pattern);

            string[] files = storeFile.GetFileNames(pattern);

            try
            {
                for (int i = 0; i < storeFile.GetFileNames(dir + "/" + fileString).Length; i++)
                {

                    //Files are prefixed with "--"

                    //Add to the list
                    //listDir.Add("--" + dir + "/" + storeFile.GetFileNames(dir + "/" + fileString)[i]);

                    Debug.WriteLine("--" + dir + "/" + storeFile.GetFileNames(dir + "/" + fileString)[i]);
                }
            }
            catch (IsolatedStorageException ise)
            {
                Debug.WriteLine("An IsolatedStorageException exception has occurred: " + ise.InnerException);
            }
            catch (Exception e)
            {
                Debug.WriteLine("An exception has occurred: " + e.InnerException);
            }
        }
        /// <summary>
        /// Collects the Paths of Directories and Files inside a given Directory relative to it.
        /// </summary>
        /// <param name="Iso">The Isolated Storage to Use</param>
        /// <param name="directory">The Directory to crawl</param>
        /// <param name="relativeSubDirectories">relative Paths to the subdirectories in the given directory, ordered top - down</param>
        /// <param name="relativeSubFiles">relative Paths to the files in the given directory and its children, ordered top - down</param>
        private static void CollectSubdirectoriesAndFilesBreadthFirst(IsolatedStorageFile Iso, string directory, out IList<string> relativeSubDirectories, out IList<string> relativeSubFiles)
        {
            var relativeDirs = new List<string>();
            var relativeFiles = new List<string>();
            var toDo = new Queue<string>();

            toDo.Enqueue(string.Empty);

            while (toDo.Count > 0)
            {
                var relativeSubDir = toDo.Dequeue();
                var absoluteSubDir = Path.Combine(directory, relativeSubDir);
                var queryString = string.Format("{0}\\*", absoluteSubDir);

                foreach (var file in Iso.GetFileNames(queryString))
                {
                    relativeFiles.Add(Path.Combine(relativeSubDir, file));
                }

                foreach (var dir in Iso.GetDirectoryNames(queryString))
                {
                    var relativeSubSubdir = Path.Combine(relativeSubDir, dir);
                    toDo.Enqueue(relativeSubSubdir);
                    relativeDirs.Add(relativeSubSubdir);
                }
            }

            relativeSubDirectories = relativeDirs;
            relativeSubFiles = relativeFiles;
        }
Exemplo n.º 3
0
 public void GetFileNames_RaisesInvalidPath()
 {
     using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly())
     {
         Assert.Throws <ArgumentException>(() => isf.GetFileNames("\0bad"));
     }
 }
        //TODO : verify we don't need the method below using Bridge
#if !BRIDGE
        // public acces´s for tests
        public static void LoadData()
        {
            // IsolatedStorageFile isoStore = IsolatedStorageFile.GetStore(IsolatedStorageScope.User | IsolatedStorageScope.Assembly, null, null);
            IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForAssembly();

            if (isoStore.GetFileNames(Filename).Length == 0)
            {
                // File not exists. Let us NOT try to DeSerialize it.
                return;
            }

            // Read the stream from Isolated Storage.
            Stream stream = new IsolatedStorageFileStream(Filename, FileMode.OpenOrCreate, isoStore);

            try
            {
                // DeSerialize the Dictionary from stream.
                object bytes = Formatter.Deserialize(stream);

                var appData = (Dictionary <string, object>)bytes;

                // Enumerate through the collection and load our Dictionary.
                IDictionaryEnumerator enumerator = appData.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    AppDictionary[enumerator.Key.ToString()] = enumerator.Value;
                }
            }
            finally
            {
                stream.Close();
            }
        }
Exemplo n.º 5
0
 public void GetFileNames_RaisesInvalidPath_Core()
 {
     // We are no longer as aggressive with filters for enumerating files
     using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly())
     {
         isf.GetFileNames("\0bad");
     }
 }
Exemplo n.º 6
0
        public static string[] GetFilesName(string path)
        {
            System.IO.IsolatedStorage.IsolatedStorageFile isf = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication();
            string searchpath = System.IO.Path.Combine(path, "*.*");

            string[] filesInSubDirs = isf.GetFileNames(searchpath);
            return(filesInSubDirs);
        }
Exemplo n.º 7
0
 public void GetFileNames_Closed_ThrowsInvalidOperationException()
 {
     using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly())
     {
         isf.Close();
         Assert.Throws <InvalidOperationException>(() => isf.GetFileNames("foo"));
     }
 }
Exemplo n.º 8
0
 public void GetFileNames_ThrowsIsolatedStorageException()
 {
     using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly())
     {
         isf.Remove();
         Assert.Throws <IsolatedStorageException>(() => isf.GetFileNames("foo"));
     }
 }
        public static List<String> GetAllFiles(string pattern, IsolatedStorageFile storeFile)
        {
            // Get the root and file portions of the search string.
            string fileString = Path.GetFileName(pattern);

            List<String> fileList = new List<String>(storeFile.GetFileNames(pattern));

            // Loop through the subdirectories, collect matches,
            // and make separators consistent.
            foreach (string directory in GetAllDirectories("*", storeFile))
            {
                foreach (string file in storeFile.GetFileNames(directory + "/" + fileString))
                {
                    fileList.Add((directory + "/" + file));
                }
            }

            return fileList;
        }
Exemplo n.º 10
0
 private void DeleteAllFilesInDirectory(IsolatedStorageFile store, string path)
 {
     if (!store.DirectoryExists(path))
     {
         return;
     }
     var files = store.GetFileNames(path + "/*");
     foreach (var file in files)
     {
         store.DeleteFile(path + "/" + file);
     }
 }
Exemplo n.º 11
0
 private void InnerClear(IsolatedStorageFile iso, string path) {
     var fs = iso.GetFileNames(string.Format("{0}/*", path));
     foreach (var f in fs) {
         iso.DeleteFile(Path.Combine(path, f));
     }
     var ds = iso.GetDirectoryNames(string.Format("{0}/*", path));
     foreach (var d in ds) {
         var sp = Path.Combine(path, d);
         this.InnerClear(iso, sp);
         iso.DeleteDirectory(sp);
     }
 }
Exemplo n.º 12
0
		// use the caller stack to execute some read operations
		private void Read (IsolatedStorageFile isf)
		{
			Assert.IsNotNull (isf.GetDirectoryNames ("*"), "GetDirectoryNames");
			Assert.IsNotNull (isf.GetFileNames ("*"), "GetFileNames");
			try {
				Assert.IsTrue (isf.CurrentSize >= 0, "CurrentSize");
				Assert.IsTrue (isf.MaximumSize >= isf.CurrentSize, "MaximumSize");
			}
			catch (InvalidOperationException) {
				// roaming
			}
		}
Exemplo n.º 13
0
        public static void RecursiveDeleteDirectory(string directory, IsolatedStorageFile store)
        {
            foreach (var fileName in store.GetFileNames(directory + "\\*"))
            {
                store.DeleteFile(directory + "\\" + fileName);
            }

            foreach (var directoryName in store.GetDirectoryNames(directory + "\\*"))
            {
                RecursiveDeleteDirectory(directory + "\\" + directoryName, store);
            }

            store.DeleteDirectory(directory);
        }
Exemplo n.º 14
0
 public override void Clear()
 {
     base.Clear();
     using ( _storage = IsolatedStorageFile.GetUserStoreForApplication() ) {
         try {
             foreach ( string file in _storage.GetFileNames( CACHE_FOLDER + @"\*" ) ) {
                 _storage.DeleteFile( GetFilePath( file ) );
             }
         }
         catch ( Exception e ) {
             e.ToString();
         }
     }
 }
		public IsolatedStorageCrawlerQueueService(Uri crawlStart, bool resume)
		{
			m_CrawlStart = crawlStart;
			m_Store = IsolatedStorageFile.GetMachineStoreForDomain();

			if (!resume)
			{
				Clean();
			}
			else
			{
				Initialize();
				m_Count = m_Store.GetFileNames(Path.Combine(WorkFolderPath, "*")).Count();
			}
		}
Exemplo n.º 16
0
 public static void DeleteDirectoryRecursively(IsolatedStorageFile storageFile, string directoryName)
 {
     var pattern = directoryName + @"\*";
     var files = storageFile.GetFileNames(pattern);
     foreach (var fileName in files)
     {
         storageFile.DeleteFile(Path.Combine(directoryName, fileName));
     }
     var dirs = storageFile.GetDirectoryNames(pattern);
     foreach (var dirName in dirs)
     {
         DeleteDirectoryRecursively(storageFile, Path.Combine(directoryName, dirName));
     }
     storageFile.DeleteDirectory(directoryName);
 }
Exemplo n.º 17
0
 public void DeleteDirectoryRecursive(IsolatedStorageFile isolatedStorageFile, String dirName)
 {
     String pattern = dirName + @"\*";
     String[] files = isolatedStorageFile.GetFileNames(pattern);
     foreach (String fName in files)
     {
         isolatedStorageFile.DeleteFile(Path.Combine(dirName, fName));
     }
     String[] dirs = isolatedStorageFile.GetDirectoryNames(pattern);
     foreach (String dName in dirs)
     {
         DeleteDirectoryRecursive(isolatedStorageFile, Path.Combine(dirName, dName));
     }
     isolatedStorageFile.DeleteDirectory(dirName);
 }
Exemplo n.º 18
0
        public static void TryToDeleteAllFiles(IsolatedStorageFile storageFolder, string directory)
        {
            if (storageFolder.DirectoryExists(directory))
            {
                try
                {
                    string[] files = storageFolder.GetFileNames(directory);
                    foreach (string File in files)
                    {
                        storageFolder.DeleteFile(directory + files);

                    }
                }
                catch (Exception)
                {
                    //ignoring the exception
                }
             }
        }
Exemplo n.º 19
0
        /// <summary>
        /// delete files in directory
        /// </summary>
        /// <param name="storageFolder"></param>
        /// <param name="directory"></param>
        private static void TryToDeleteAllFiles(IsolatedStorageFile storageFolder, string directory)
        {
            if (storageFolder.DirectoryExists(directory))
            {
                try
                {
                    string[] files = storageFolder.GetFileNames(directory);

                    foreach (string file in files)
                    {
                        storageFolder.DeleteFile(directory + file);
                    }
                }
                catch (Exception)
                {
                    // could be in use
                }
            }
        }
Exemplo n.º 20
0
        private static void CleanupLogs(IsolatedStorageFile store, string logFolder)
        {
            var files = store.GetFileNames(logFolder);
            var fileCount = files.Count();
            if (fileCount > MAX_FILE_COUNT - 1)
            {
                var filesAgeAsc = from file in files
                                  let age = store.GetCreationTime(file)
                                  orderby age ascending
                                  select file;
                var deleteFiles = filesAgeAsc.Take(fileCount - MAX_FILE_COUNT + 1);

                foreach (var file in deleteFiles)
                {
                    var filePath = Path.Combine(logFolder, file);
                    store.DeleteFile(filePath);
                }
            }
        }
Exemplo n.º 21
0
        public static void DeleteDirectory(IsolatedStorageFile store, String root)
        {
            String dir = root;

            //  delete file in current dir
            foreach (String file in store.GetFileNames(dir + "/*"))
            {
                store.DeleteFile(dir + "/" + file);
            }

            //  delete sub-dir
            foreach (String subdir in store.GetDirectoryNames(dir + "/*"))
            {
                DeleteDirectory(store, dir + "/" + subdir + "/");
            }

            //  delete current dir
            store.DeleteDirectory(dir);
        }
Exemplo n.º 22
0
        public string Read(string filename)
        {
            string result = string.Empty;

            System.IO.IsolatedStorage.IsolatedStorageFile isoStore =
                System.IO.IsolatedStorage.IsolatedStorageFile.
                GetUserStoreForDomain();
            try
            {
                // Checks to see if the options.txt file exists.
                if (isoStore.GetFileNames(filename).GetLength(0) != 0)
                {
                    // Opens the file because it exists.
                    System.IO.IsolatedStorage.IsolatedStorageFileStream isos =
                        new System.IO.IsolatedStorage.IsolatedStorageFileStream
                            (filename, System.IO.FileMode.Open, isoStore);
                    System.IO.StreamReader reader = null;
                    try
                    {
                        reader = new System.IO.StreamReader(isos);

                        // Reads the values stored.
                        result = reader.ReadLine();
                    }
                    catch (Exception ex)
                    {
                        System.Diagnostics.Debug.WriteLine
                            ("Cannot read options " + ex.ToString());
                    }
                    finally
                    {
                        reader.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine
                    ("Cannot read options " + ex.ToString());
            }
            return(result);
        }
Exemplo n.º 23
0
        /// <summary>
        /// Loads local audio information.
        /// </summary>
        public void ReadAudioFileInfo()
        {
            AudioFiles.Clear();

            // Load the image which was filtered from isolated app storage.
            System.IO.IsolatedStorage.IsolatedStorageFile myStore = IsolatedStorageFile.GetUserStoreForApplication();

            try
            {
                string[] fileNames = myStore.GetFileNames();
                foreach (string s in fileNames)
                {
                    AudioFileModel audioFile = new AudioFileModel();
                    audioFile.FileName = s;
                    IsolatedStorageFileStream fileStream = myStore.OpenFile(s, System.IO.FileMode.Open, System.IO.FileAccess.Read);
                    audioFile.FileSize = "" + fileStream.Length + " bytes";

                    // Read sample rate and channel count
                    Encoding encoding = Encoding.UTF8;
                    byte[]   bytes    = new byte[4];

                    // channel count
                    fileStream.Seek(22, SeekOrigin.Begin);
                    fileStream.Read(bytes, 0, 2);
                    audioFile.ChannelCount = BitConverter.ToInt16(bytes, 0);

                    // sample rate
                    fileStream.Read(bytes, 0, 4);
                    audioFile.SampleRate = BitConverter.ToInt32(bytes, 0);

                    audioFile.FileLength = "" + fileStream.Length / (2 * audioFile.SampleRate * audioFile.ChannelCount) + " seconds";
                    AudioFiles.Add(audioFile);

                    fileStream.Dispose();
                }
            }
            catch
            {
                MessageBox.Show("Error while trying to read audio files.");
            }
        }
Exemplo n.º 24
0
        // Writes the button options to the isolated storage.
        public void Write(string filename, string content)
        {
            System.IO.IsolatedStorage.IsolatedStorageFile isoStore =
                System.IO.IsolatedStorage.IsolatedStorageFile.
                GetUserStoreForDomain();
            try
            {
                // Checks if the file exists and, if it does, tries to delete it.
                if (isoStore.GetFileNames(filename).GetLength(0) != 0)
                {
                    isoStore.DeleteFile(filename);
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine
                    ("Cannot delete file " + ex.ToString());
            }

            // Creates the options file and writes the button options to it.
            System.IO.StreamWriter writer = null;
            try
            {
                System.IO.IsolatedStorage.IsolatedStorageFileStream isos = new
                                                                           System.IO.IsolatedStorage.IsolatedStorageFileStream(filename,
                                                                                                                               System.IO.FileMode.CreateNew, isoStore);

                writer = new System.IO.StreamWriter(isos);
                writer.WriteLine(content);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine
                    ("Cannot write options " + ex.ToString());
            }
            finally
            {
                writer.Close();
            }
        }
Exemplo n.º 25
0
        /// <summary>
        /// Returns the first-in-queue report file. If there are no files queued, returns <see langword="null"/>.
        /// </summary>
        /// <returns>Report file stream.</returns>
        public Stream GetFirstReportFile(out string fileName)
        {
            _isoStore = IsolatedStorageFile.GetStore(IsolatedStorageScope.User | IsolatedStorageScope.Assembly | IsolatedStorageScope.Domain, null, null);

            fileName = _isoStore.GetFileNames("Exception_*.zip").FirstOrDefault();
            if (fileName == null)
            {
                return null;
            }

            try
            {
                return new IsolatedStorageFileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.None);
            }
            catch (IOException exception)
            {
                // If the file is locked (as per IOException), then probably another instance of the library is already accessing
                // the file so let the other instance handle the file
                Logger.Error("Cannot access the report file at isolated storage (it is probably locked, see the inner exception): [Isolated Storage Directory]\\" + fileName, exception);
                return null;
            }
        }
Exemplo n.º 26
0
        public void CopyDirectory(string sourcePath, string destinationPath, IsolatedStorageFile iso)
        {
            if (!iso.DirectoryExists(sourcePath))
            return;

              var folders = iso.GetDirectoryNames(sourcePath + "/" + "*.*");

              foreach (var folder in folders)
              {
            string sourceFolderPath = sourcePath + "/" + folder;
            string destinationFolderPath = destinationPath + "/" + folder;

            iso.CreateDirectory(destinationFolderPath);
            CopyDirectory(sourceFolderPath, destinationFolderPath, iso);
              }

              foreach (var file in iso.GetFileNames(sourcePath + "/" + "*.*"))
              {
            string sourceFilePath = sourcePath + "/" + file;
            string destinationFilePath = destinationPath + "/" + file;

            iso.CopyFile(sourceFilePath, destinationFilePath);
              }
        }
Exemplo n.º 27
0
        private void ImportSavegamesCache(IsolatedStorageFile isf)
        {
            string[] gwsFiles = isf.GetFileNames(GetCachePathCore("*.gws"));
            if (gwsFiles == null)
            {
                return;
            }

            // For each file, imports its metadata.
            List<CartridgeSavegame> cSavegames = new List<CartridgeSavegame>();
            foreach (string file in gwsFiles)
            {
                try
                {
                    cSavegames.Add(CartridgeSavegame.FromCache(GetCachePathCore(file), isf));
                }
                catch (Exception ex)
                {
                    // Outputs the exception.
                    System.Diagnostics.Debug.WriteLine("CartridgeTag: WARNING: Exception during savegame import.");
                    DebugUtils.DumpException(ex);
                }
            }

            // Sets the savegame list.
            _savegames = cSavegames;
            RaisePropertyChanged("Savegames");
        }
Exemplo n.º 28
0
        private void DeleteDirectory(string path, IsolatedStorageFile iso)
        {
            if (!iso.DirectoryExists(path))
            return;

              var folders = iso.GetDirectoryNames(path + "/" + "*.*");

              foreach (var folder in folders)
              {
            string folderPath = path + "/" + folder;
            DeleteDirectory(folderPath, iso);
              }

              foreach (var file in iso.GetFileNames(path + "/" + "*.*"))
              {
            iso.DeleteFile(path + "/" + file);
              }

              if (path != "")
            iso.DeleteDirectory(path);
        }
Exemplo n.º 29
0
 /// <summary>
 /// Deletes the saved state files from isolated storage.
 /// </summary>
 private void DeleteState(IsolatedStorageFile storage)
 {
     // get all of the files in the directory and delete them
     string[] files = storage.GetFileNames("ScreenManager\\*");
     foreach (string file in files)
     {
         storage.DeleteFile(Path.Combine("ScreenManager", file));
     }
 }
        private void ScanDir(IsolatedStorageFile store, string directory, bool recurse)
        {
            
            try
            {
                string fileSearchPath = Path.Combine(directory, "*.*");
                string[] names = store.GetFileNames(fileSearchPath);

                bool hasMatch = false;
                for (int fileIndex = 0; fileIndex < names.Length; ++fileIndex)
                {
                    if (!fileFilter_.IsMatch(names[fileIndex]))
                    {
                        names[fileIndex] = null;
                    }
                    else
                    {
                        hasMatch = true;
                    }
                }

                OnProcessDirectory(directory, hasMatch);

                if (alive_ && hasMatch)
                {
                    foreach (string fileName in names)
                    {
                        var filePath = Path.Combine(directory, fileName);
                        try
                        {  
                            OnProcessFile(filePath);
                            if (!alive_)
                            {
                                break;
                            }
                        }
                        catch (Exception e)
                        {
                            if (!OnFileFailure(filePath, e))
                            {
                                throw;
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                if (!OnDirectoryFailure(directory, e))
                {
                    throw;
                }
            }

            if (alive_ && recurse)
            {
                try
                {
                    string[] names = store.GetDirectoryNames(Path.Combine(directory, "*"));

                    foreach (string subdir in names)
                    {
                        var fulldir = Path.Combine(directory, subdir);
                        if ((directoryFilter_ == null) || (directoryFilter_.IsMatch(fulldir)))
                        {
                            ScanDir(store, fulldir, true);
                            if (!alive_)
                            {
                                break;
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    if (!OnDirectoryFailure(directory, e))
                    {
                        throw;
                    }
                }
            }
        }
        /// <summary>
        /// Evict an entry if we need to make room for a new one.
        /// </summary>
        /// <remarks>
        /// "A cache without an eviction policy is a memory leak"
        /// We might run into quota limits on IsolatedStorage.  We need to check those, and evict files to make room. 
        /// 
        /// Cache eviction policy is "least recently updated"
        /// Note this is not the same as least recently used.
        /// Rather, we're evicting the entry that will expire soonest.
        /// 
        /// This function assumes the caller has already locked fileAccessSync
        /// </remarks>
        /// <param name="iso"></param>
        private void EvictIfNecessary(IsolatedStorageFile iso)
        {
            if (metadata.GetNumberEntries() >= this.Capacity)
            {
                string[] filesInCache = iso.GetFileNames(this.Name + "\\*");

                // This should never happen, but if the file count doesn't match
                // go and clean up the cache
                if (filesInCache.Length > metadata.GetNumberEntries())
                {
                    Debug.Assert(false);

                    foreach (string filename in filesInCache)
                    {
                        // the GetFileNames call above does not return qualified paths, but we expect those for the rest of the calls
                        string qualifiedFilename = Path.Combine(this.Name, filename);
                        DateTime? updateTime = metadata.GetUpdateTime(qualifiedFilename);
                        if (null == updateTime)
                        {
                            // Then we have a file in the cache, but no record of it being put there... clean it up
                            // Most common way to hit this would be that I changed the internal naming format between versions.
                            iso.DeleteFile(qualifiedFilename);
                        }
                    }
                }

                KeyValuePair<string, DateTime> oldestFile = metadata.GetOldestFile();

                // If we are over capacity, there should always be at least one over-capacity file
                Debug.Assert(string.IsNullOrEmpty(oldestFile.Key) == false);

                if (string.IsNullOrEmpty(oldestFile.Key) == false)
                {
                    iso.DeleteFile(oldestFile.Key);

                    metadata.RemoveUpdateTime(oldestFile.Key);
                    CacheEvictions++;
                }
            }
        }
Exemplo n.º 32
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            myLibraryItemNames = new List<Xassida>();

            BookPage titlePage, tardioumanePage, bp;

            LoadXassida();

            this.DataContext = currentXassida;

            PagesCollection = new PaginatedCollection<Beyit>(currentXassida.Beyits);

            /// the title of the xassida will be the first page
            ///
            titlePage = new BookPage();

            StackPanel p = new StackPanel() { VerticalAlignment = VerticalAlignment.Center };
            TextBlock tPageTb = new TextBlock()
            {
                Text = currentXassida.Titre,
                FontSize = 35,
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment = VerticalAlignment.Center,
                TextAlignment = TextAlignment.Center,
                TextWrapping = TextWrapping.Wrap
            };
            p.Children.Add(tPageTb);
            titlePage.Content = p;

            readerBook.Items.Add(titlePage);

            tardioumanePage = new BookPage();
            tardioumanePage.Content = new TextBlock()
            {
                Text = currentXassida.Tardioumane,
                TextWrapping = TextWrapping.WrapWithOverflow,
                VerticalAlignment = VerticalAlignment.Center,

            };

            readerBook.Items.Add(tardioumanePage);

            for (int i = 0; i < PagesCollection.PagesCount; i++)
            {

                bp = new BookPage();
                StackPanel container = new StackPanel() { Orientation = Orientation.Vertical, VerticalAlignment = VerticalAlignment.Center };

                foreach (Beyit beyit in PagesCollection.GetData(i))
                {

                    DockPanel c = new DockPanel();
                    foreach (Bahru bahru in beyit.Bahrus)
                    {
                        TextBlock tb = new TextBlock() { Text = bahru.Contenu, Margin = new Thickness(4, 6, 4, 6), Width = 50 };
                        c.Children.Add(tb);
                    }

                    container.Children.Add(c);
                }

                container.Children.Add(new TextBlock() { Text = String.Format("page {0}", (i + 1).ToString()), Foreground = SystemColors.GrayTextBrush, FontSize = 7, Margin = new Thickness(0, 10, 0, 10) });

                bp.Content = container;
                readerBook.Items.Add(bp);

            }

            AppStore = IsolatedStorageFile.GetUserStoreForDomain();
            // Check for files saved in isolated storage
            foreach (string file in AppStore.GetFileNames())
            {
                myLibraryItemNames.Add(new Xassida() { Titre = file});
            }

            // Set the items source of the myLibrary List view

            myLibraryListView.ItemsSource = myLibraryItemNames;
        }
Exemplo n.º 33
0
        private static void Upgrade(IsolatedStorageFile store)
        {
            var files = new List<string>(
                store.GetFileNames());

            if (!files.Contains("Database.kdbx"))
                return;

            var appSettings = IsolatedStorageSettings
                .ApplicationSettings;

            string url;
            if (!appSettings.TryGetValue("Url", out url))
                url = null;

            var info = new DatabaseInfo();

            using (var fs = store.OpenFile("Database.kdbx", FileMode.Open))
            {
                var source = string.IsNullOrEmpty(url)
                    ? "WinPass" : DatabaseUpdater.WEB_UPDATER;

                var details = new DatabaseDetails
                {
                    Url = url,
                    Source = source,
                    Type = SourceTypes.OneTime,
                    Name = "WinPass 1.x database",
                };

                info.SetDatabase(fs, details);
            }

            store.DeleteFile("Database.kdbx");
            store.DeleteFile("Protection.bin");
            store.DeleteFile("Decrypted.xml");
        }
Exemplo n.º 34
0
 // Determinates whether the given file exists in the given storage
 private static bool FileExists(IsolatedStorageFile storage, string fileName)
 {
     var files = storage.GetFileNames(fileName);
     return files.Length != 0;
 }
Exemplo n.º 35
0
 private static IEnumerable<string> GetDebugFiles(IsolatedStorageFile isf, bool includeRawData)
 {
     return isf.GetFileNames("/Debug/")
         .Where(s => includeRawData || !s.Contains("rawdata"));
 }
Exemplo n.º 36
0
 // Can't delete unless empty. Must recursively delete files and folders
 private static void DeleteDirectory(IsolatedStorageFile storage, string dir)
 {
     foreach (var file in storage.GetFileNames(Path.Combine(dir, "*")))
     {
         storage.DeleteFile(Path.Combine(dir, file));
     }
     foreach (var subDir in storage.GetDirectoryNames(Path.Combine(dir, "*")))
     {
         DeleteDirectory(storage, Path.Combine(dir, subDir));
     }
     storage.DeleteDirectory(dir);
 }
Exemplo n.º 37
0
        private void CopyDirectory(string sourceDir, string destDir, IsolatedStorageFile isoFile)
        {
            string path = File.AddSlashToDirectory(sourceDir);

            bool bExists = isoFile.DirectoryExists(destDir);

            if (!bExists)
            {
                isoFile.CreateDirectory(destDir);
            }

            destDir = File.AddSlashToDirectory(destDir);

            string[] files = isoFile.GetFileNames(path + "*");

            if (files.Length > 0)
            {
                foreach (string file in files)
                {
                    isoFile.CopyFile(path + file, destDir + file, true);
                }
            }
            string[] dirs = isoFile.GetDirectoryNames(path + "*");
            if (dirs.Length > 0)
            {
                foreach (string dir in dirs)
                {
                    CopyDirectory(path + dir, destDir + dir, isoFile);
                }
            }
        }
Exemplo n.º 38
0
 /// <summary>
 /// Deletes the saved state files from isolated storage.
 /// </summary>
 private void DeleteState(IsolatedStorageFile storage)
 {
     // glob on all of the files in the directory and delete them
     string[] files = storage.GetFileNames(System.IO.Path.Combine(m_sStorageDirName, "*"));
     foreach (string file in files)
     {
         storage.DeleteFile(Path.Combine(m_sStorageDirName, file));
     }
                 }
Exemplo n.º 39
0
        // 用递归方法增加目录/文件
        void AddFileToDirectory(IsoDirectory dir, IsolatedStorageFile isf)
        {
            string[] childrendir, childrenfile;
            if (string.IsNullOrEmpty(dir.FilePath))
            {
                childrendir = isf.GetDirectoryNames();
                childrenfile = isf.GetFileNames();
            }
            else
            {
                childrendir = isf.GetDirectoryNames(dir.FilePath + "/");
                childrenfile = isf.GetFileNames(dir.FilePath + "/");
            }

            // 增加目录实体
            foreach (var dirname in childrendir)
            {
                var childdir = new IsoDirectory(dirname, dir.FilePath + "/" + dirname);
                AddFileToDirectory(childdir, isf);
                dir.Children.Add(childdir);
            }

            // 增加文件实体
            foreach (var filename in childrenfile)
            {
                dir.Children.Add(new IsoFile(filename, dir.FilePath + "/" + filename));
            }
        }