コード例 #1
0
        /// <summary>
        /// create a new bucket in cloud
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btNewBucket_Click(object sender, RoutedEventArgs e)
        {
            //create the bucket
            InputWindow dlg = new InputWindow("New Bucket", "Enter the new bucket name.");
            var         ret = dlg.ShowDialog();

            if (!ret.HasValue || ret.Value == false)
            {
                return;
            }

            //check the return
            string name = dlg.Questions[0].Answer;

            if (name.IndexOf(' ') != -1)
            {
                MessageBox.Show("The new bucket name can not contain spaces.");
                return;
            }
            else if (Buckets.Any(b => b.Equals(name, StringComparison.InvariantCultureIgnoreCase)))
            {
                MessageBox.Show("There is already a bucket with the name: " + name);
                return;
            }

            //create new directory
            if (!CloudStorage.NewDirectory(name))
            {
                MessageBox.Show("There was an error creating the bucket.");
                return;
            }
            //refresh the bucket list
            RefreshBuckets();
        }