예제 #1
0
        private void DeleteFolder(FolderTreeViewModel item)
        {
            if (MessageBox.Show(Window.GetWindow(this), "Are you sure you want to delete this folder and everything it contains?",
                                "Delete folder?", MessageBoxButton.YesNoCancel, MessageBoxImage.Question) != MessageBoxResult.Yes)
            {
                return;
            }

            if (MessageBox.Show(Window.GetWindow(this), "Are you SURE?",
                                "Delete folder?", MessageBoxButton.YesNoCancel, MessageBoxImage.Question) != MessageBoxResult.Yes)
            {
                return;
            }

            _amazon.DeleteFolder(item.Prefix);
            FolderTreeViewModel parentFolder = FolderTree.GetParentItem(item);

            if (parentFolder != null)
            {
                GetBucketContents(parentFolder);
            }
            else
            {
                GetBucketContents(null);
            }
        }
예제 #2
0
        private void doFolderRename(FolderTreeViewModel item, string newName)
        {
            string           originalPrefix = item.Prefix[item.Prefix.Length - 1] != '/' ? item.Prefix + "/" : item.Prefix;
            string           newPrefix      = newName[newName.Length - 1] != '/' ? newName + "/" : newName;
            BackgroundWorker worker         = new BackgroundWorker();

            worker.DoWork += (s, e) =>
            {
                List <S3Object> objects = _amazon.GetObjectsInBucket(originalPrefix);

                foreach (var toCopy in objects)
                {
                    string newObjectKey = newPrefix + toCopy.Key.Substring(originalPrefix.Length);
                    _amazon.CopyFile(toCopy.Key, newObjectKey);
                    _amazon.DeleteFile(toCopy.Key);
                }
            };
            worker.RunWorkerCompleted += (s, e) =>
            {
                this.IsWorking = false;
                if (e.Error == null)
                {
                    FolderTreeViewModel parentFolder = FolderTree.GetParentItem(item);
                    if (parentFolder != null)
                    {
                        GetBucketContents(parentFolder);
                    }
                    else
                    {
                        GetBucketContents(null);
                    }
                }
                else
                {
                    MessageBox.Show(Window.GetWindow(this), "Error occured: " + e.Error.Message, "Error");
                }
            };
            worker.RunWorkerAsync();
            this.IsWorking = true;
        }