From 2c39a1ef8c13bd8d0321f79b0ce2850d0a590b45 Mon Sep 17 00:00:00 2001 From: Ian C Date: Wed, 27 Jun 2012 22:49:23 +0000 Subject: Done Save, Load and Delete dialogs. --- .../ViewModels/FileInfo.cs | 27 ++++++++++++++++------ 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'Noddybox.WindowsPhone.Silverlight/ViewModels/FileInfo.cs') diff --git a/Noddybox.WindowsPhone.Silverlight/ViewModels/FileInfo.cs b/Noddybox.WindowsPhone.Silverlight/ViewModels/FileInfo.cs index 3c680c7..9adb0f3 100644 --- a/Noddybox.WindowsPhone.Silverlight/ViewModels/FileInfo.cs +++ b/Noddybox.WindowsPhone.Silverlight/ViewModels/FileInfo.cs @@ -27,6 +27,7 @@ using System.Windows.Media.Animation; using System.Windows.Shapes; using System.IO.IsolatedStorage; using System.Collections.Generic; +using System.Text.RegularExpressions; namespace Noddybox.WindowsPhone.Silverlight.ViewModels { @@ -45,15 +46,21 @@ namespace Noddybox.WindowsPhone.Silverlight.ViewModels /// public string Name {get; private set;} + /// + /// The full path of the file. + /// + public string Path {get; private set;} + /// /// Constructor. /// /// Whether the file is a folder. /// The file name. - public FileInfo (bool isFolder, string name) + public FileInfo (bool isFolder, string name, string path) { IsFolder = isFolder; Name = name; + Path = path; } /// @@ -61,7 +68,7 @@ namespace Noddybox.WindowsPhone.Silverlight.ViewModels /// /// The folder to search, which must end with a "/". Uses root folder is empty or null. /// A list of the files and directories. A ".." directory is added if not the root folder. - public static List GetFiles(string folder) + public static List GetFiles(string folder, string mask) { bool root = false; List flist = new List(); @@ -79,19 +86,25 @@ namespace Noddybox.WindowsPhone.Silverlight.ViewModels if (!root) { - flist.Add(new FileInfo(true, "..")); + flist.Add(new FileInfo(true, "..", folder + "..")); } IsolatedStorageFile iso = IsolatedStorageFile.GetUserStoreForApplication(); - foreach (string s in iso.GetDirectoryNames(folder + "*")) + List folders = new List(iso.GetDirectoryNames(folder + "*")); + List files = new List(iso.GetFileNames(folder + mask)); + + folders.Sort(); + files.Sort(); + + foreach (string s in folders) { - flist.Add(new FileInfo(true, s)); + flist.Add(new FileInfo(true, s, folder + s)); } - foreach (string s in iso.GetFileNames(folder + "*")) + foreach (string s in files) { - flist.Add(new FileInfo(false, s)); + flist.Add(new FileInfo(false, s, folder + s)); } return flist; -- cgit v1.2.3