Пример #1
0
 private void mDelSel_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show(this, "選択したファイル・フォルダを削除しますか?", Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) != DialogResult.Yes)
     {
         return;
     }
     foreach (Ent ent in lvF.SelectedItems.Cast <ListViewItem>().Select(p => (Ent)p.Tag))
     {
         using (GenRes killed = DInfo.Delete(ent.FullUrl, conn)) {
         }
     }
     RefreshView();
 }
Пример #2
0
        private void bNewFolder_Click(object sender, EventArgs e)
        {
            String name = Interaction.InputBox("フォルダ名称", "", "", -1, -1);

            if (name.Length == 0)
            {
                return;
            }

            using (GenRes newf = DInfo.NewFolder(UUt.CombineFile(navi, name), conn)) {
                if (!newf.Success)
                {
                    MessageBox.Show(this, "フォルダの作成に失敗しました:" + newf.err.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            RefreshView();
        }
Пример #3
0
 private void mRenameSel_Click(object sender, EventArgs e)
 {
     foreach (Ent ent in lvF.SelectedItems.Cast <ListViewItem>().Select(p => (Ent)p.Tag))
     {
         String newname = Interaction.InputBox("新しい名前", "", ent.Name, -1, -1);
         if (newname.Length == 0)
         {
             break;
         }
         using (GenRes moved = DInfo.Move(ent.FullUrl, new Uri(ent.SelfFullUrl, newname + "/"), conn)) {
             if (!moved.Success)
             {
                 MessageBox.Show(this, "フォルダの移動に失敗しました:" + moved.err.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             }
         }
         RefreshView();
         break;
     }
 }
Пример #4
0
        void Open(Uri uri)
        {
            OpenRes res = DInfo.Open(uri, conn);

            if (res.err == null)
            {
                lvF.Items.Clear();
                firstNavi  = firstNavi ?? navi;
                navi       = res.baseUrl;
                tbUrl.Text = navi.ToString();
                foreach (Ent ent in res.Ents)
                {
                    if (ent.IsSelf)
                    {
                        lvF.Tag = ent;
                        continue;
                    }
                    ListViewItem lvi    = new ListViewItem(ent.Name);
                    Int64?       length = ent.ContentLength;
                    lvi.SubItems.Add(length.HasValue ? length.Value.ToString("#,##0") : "");
                    lvi.SubItems.Add(ent.IsDir ? "フォルダ" : "ファイル");
                    DateTime?mt = ent.Mt;
                    lvi.SubItems.Add((mt.HasValue) ? mt.Value.ToString() : "");

                    lvi.ImageKey = ent.IsDir ? "D" : "F";
                    lvi.Tag      = ent;
                    lvF.Items.Add(lvi);
                }
            }
            else
            {
                MessageBox.Show(this, "失敗しました:" + res.err.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                if (tbUrl.Text.Length == 0)
                {
                    tbUrl.Text = (firstNavi = uri).ToString();
                }
            }
        }
Пример #5
0
            public UTRes UploadThem(String[] alfp, Uri baseUri)
            {
                foreach (String fp in alfp)
                {
                    if (cancel.WaitOne(0, false))
                    {
                        return(UTRes.Cancel);
                    }
                    Uri uriTo = UUt.CombineFile(baseUri, Path.GetFileName(fp));
                    using (HeadRes head = DInfo.Head(uriTo, conn)) {
                        head.Dispose();
                        if (0 == (File.GetAttributes(fp) & FileAttributes.Directory))
                        {
                            if (head.Exists)
                            {
                                switch (QueryOvwr(head.baseUri.ToString()))
                                {
                                case DialogResult.Yes:
                                    break;

                                case DialogResult.No:
                                    continue;

                                case DialogResult.Cancel:
                                    return(UTRes.Cancel);
                                }
                            }
                            head.Dispose();
                            using (GenRes uploaded = DInfo.Upload2(uriTo, fp, conn, nio, cancel)) {
                                if (cancel.WaitOne(0, true))
                                {
                                    using (GenRes rest = DInfo.Delete(uriTo, conn)) {
                                    }
                                }
                            }
                            using (GenRes set = DInfo.SetMt(uriTo, fp, conn)) {
                            }
                        }
                        else
                        {
                            Uri uriDir = UUt.CombineFile(baseUri, Path.GetFileName(fp));

                            if (!head.Exists)
                            {
                                using (GenRes newf = DInfo.NewFolder(uriTo, conn)) {
                                    if (!newf.Success)
                                    {
                                        continue;
                                    }
                                }
                            }

                            switch (UploadThem(Directory.GetFileSystemEntries(fp), uriDir))
                            {
                            case UTRes.Cancel:
                                return(UTRes.Cancel);
                            }
                        }
                    }
                }
                return(UTRes.Ok);
            }