コード例 #1
0
        public bool AddLocation(string path)
        {
            if (CanAdd(path))
            {
                SystemDirectory dir = new SystemDirectory(path, Dispatcher.CurrentDispatcher);
                StackLocations.Add(dir);

                return(true);
            }

            return(false);
        }
コード例 #2
0
        private void deserializeStacks()
        {
            if (ShellHelper.Exists(stackConfigFile))
            {
                System.Xml.XmlReader reader        = System.Xml.XmlReader.Create(stackConfigFile);
                List <string>        locationPaths = serializer.Deserialize(reader) as List <string>;
                foreach (string path in locationPaths)
                {
                    AddLocation(path);
                }
                reader.Close();
            }
            else
            {
                // Add some default folders on FirstRun

                // Check for Documents Folder
                string myDocsPath = Interop.KnownFolders.GetPath(Interop.KnownFolder.Documents);
                if (Directory.Exists(myDocsPath))
                {
                    SystemDirectory myDocsSysDir = new SystemDirectory(myDocsPath, Dispatcher.CurrentDispatcher);
                    // Don't duplicate defaults
                    if (!StackLocations.Contains(myDocsSysDir))
                    {
                        StackLocations.Add(myDocsSysDir);
                    }
                }
                // Check for Downloads folder
                string downloadsPath = Interop.KnownFolders.GetPath(Interop.KnownFolder.Downloads);
                if (Directory.Exists(downloadsPath))
                {
                    SystemDirectory downloadsSysDir = new SystemDirectory(downloadsPath, Dispatcher.CurrentDispatcher);
                    // Don't duplicate defaults
                    if (!StackLocations.Contains(downloadsSysDir))
                    {
                        StackLocations.Add(downloadsSysDir);
                    }
                }

                // save
                serializeStacks();
            }
        }