private void CreateFolderDialogue_Load(object sender, EventArgs e)
        {
            foreach (string dirName in Directory.GetDirectories(Environment.GetFolderPath(Environment.SpecialFolder.Favorites)))
            {
                DirectoryInfo dirInfo = new DirectoryInfo(dirName);
                FavouriteDirectoryInfo favouriteDirectoryInfo = new FavouriteDirectoryInfo();
                favouriteDirectoryInfo.DirectoryName = dirInfo.Name;
                favouriteDirectoryInfo.FullPath = dirName;
                this.FavouritesComboBox.Items.Add(favouriteDirectoryInfo);
            }

            this.FavouritesComboBox.SelectedIndex = 0;
        }
Exemplo n.º 2
0
        private void CreateFolderDialogue_Load(object sender, EventArgs e)
        {
            foreach (string dirName in Directory.GetDirectories(Environment.GetFolderPath(Environment.SpecialFolder.Favorites)))
            {
                DirectoryInfo          dirInfo = new DirectoryInfo(dirName);
                FavouriteDirectoryInfo favouriteDirectoryInfo = new FavouriteDirectoryInfo();
                favouriteDirectoryInfo.DirectoryName = dirInfo.Name;
                favouriteDirectoryInfo.FullPath      = dirName;
                this.FavouritesComboBox.Items.Add(favouriteDirectoryInfo);
            }

            this.FavouritesComboBox.SelectedIndex = 0;
        }
        private void CreateButton_Click(object sender, EventArgs e)
        {
            if (this.FolderNameTextBox.Text == string.Empty)
            {
                MessageBox.Show("You must provide a Name for the new folder.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                return;
            }

            this.newFavouriteDirectoryInfo = new FavouriteDirectoryInfo();
            this.newFavouriteDirectoryInfo.DirectoryName = this.FolderNameTextBox.Text;

            if (this.FavouritesComboBox.Text == "Favourites")
            {
                newFavouriteDirectoryInfo.FullPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Favorites), this.FolderNameTextBox.Text);
            }
            else
            {
                FavouriteDirectoryInfo parentDirectoryInfo = (FavouriteDirectoryInfo)this.FavouritesComboBox.SelectedItem;
                newFavouriteDirectoryInfo.FullPath = Path.Combine(newFavouriteDirectoryInfo.FullPath, this.FolderNameTextBox.Text);
            }

            Directory.CreateDirectory(newFavouriteDirectoryInfo.FullPath);
        }
Exemplo n.º 4
0
        private void CreateButton_Click(object sender, EventArgs e)
        {
            if (this.FolderNameTextBox.Text == string.Empty)
            {
                MessageBox.Show("You must provide a Name for the new folder.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                return;
            }

            this.newFavouriteDirectoryInfo = new FavouriteDirectoryInfo();
            this.newFavouriteDirectoryInfo.DirectoryName = this.FolderNameTextBox.Text;

            if (this.FavouritesComboBox.Text == "Favourites")
            {
                newFavouriteDirectoryInfo.FullPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Favorites), this.FolderNameTextBox.Text);
            }
            else
            {
                FavouriteDirectoryInfo parentDirectoryInfo = (FavouriteDirectoryInfo)this.FavouritesComboBox.SelectedItem;
                newFavouriteDirectoryInfo.FullPath = Path.Combine(newFavouriteDirectoryInfo.FullPath, this.FolderNameTextBox.Text);
            }

            Directory.CreateDirectory(newFavouriteDirectoryInfo.FullPath);
        }
Exemplo n.º 5
0
        private void AddButton_Click(object sender, EventArgs e)
        {
            if (this.NameTextBox.Text == string.Empty)
            {
                MessageBox.Show("You must provide a Display Name for the Favourite", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                return;
            }

            if (this.currentAddress == string.Empty)
            {
                MessageBox.Show("You must provide a Url for the Favourite", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                return;
            }

            Uri favouriteUri = null;

            if (!Uri.TryCreate(this.currentAddress, UriKind.RelativeOrAbsolute, out favouriteUri))
            {
                MessageBox.Show("Please provide a valid Url", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                return;
            }

            string favouriteFileName;

            if (this.FavouritesComboBox.Text == "Favourites")
            {
                favouriteFileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Favorites), this.NameTextBox.Text + ".url");
            }
            else
            {
                FavouriteDirectoryInfo favouriteDirectoryInfo = (FavouriteDirectoryInfo)this.FavouritesComboBox.SelectedItem;
                favouriteFileName = Path.Combine(favouriteDirectoryInfo.FullPath, this.NameTextBox.Text + ".url");
            }

            WritePrivateProfileString("InternetShortcut", "URL", favouriteUri.ToString(), favouriteFileName);
        }