c# V盘文件(手机资源)管理系统

2013-10-14号开始参与V盘项目,这个项目主要是V盘存取手机内部宝贵的短信、通讯录、备忘录、文件、音乐、视频、相片的管控功能一共分三个版本,pc、android、ios三部分的客户端进行开发。

我这边主要说说winfrom版本。

(1)复制 粘贴 ,pc向winfrom和winfrom向pc上复制 粘贴功能code

private void 复制ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                System.Collections.Specialized.StringCollection files = new System.Collections.Specialized.StringCollection();
                al.Clear();
                path = listView1.Items[listView1.SelectedIndices[0]].SubItems[4].Text;
                for (int i = 0; i < listView1.SelectedItems.Count; i++)
                {
                    al.Add(listView1.Items[listView1.SelectedIndices[i]].SubItems[4].Text);
                    files.Add(listView1.Items[listView1.SelectedIndices[i]].SubItems[4].Text);
                }


                Clipboard.SetFileDropList(files);
                MyPath = path;
                T = 1;
            }
            catch
            {
                MessageBox.Show("请选择文件!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }


private void 粘贴ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int files = Clipboard.GetFileDropList().Count;


            frmProcessBar frm = new frmProcessBar();
            frmProcessBar frm2 = new frmProcessBar();




            if (files > 0)//电脑上的往V盘中复制
            {


                frm.Increase(false);
                frm.Show();
                for (int s = 0; s < files; s++)
                {
                    try
                    {
                        string fli = Clipboard.GetFileDropList()[s].ToString();
                        string fname = fli.Substring(fli.LastIndexOf("\\") + 1, fli.Length - fli.LastIndexOf("\\") - 1);
                        string fpath = bc.Mpath() + "\\" + fname;
                        string newtype = fli.Substring(fli.LastIndexOf(".") + 1, fli.Length - fli.LastIndexOf(".") - 1).ToLower();
                        if (fli.LastIndexOf(".") == -1)
                        {
                            if (Directory.Exists(newtype))
                            {
                                bc.Files_Copy(fpath, newtype);
                                //DirectoryInfo di = new DirectoryInfo(newtype);
                                //di.Delete(true);
                            }
                        }
                        switch (FileType)//先卡关类型
                        {
                            case "image":
                                if (newtype == "bmp" || newtype == "gif" || newtype == "png" || newtype == "jpg" || newtype == "jpeg" || newtype == "jpe")
                                {
                                    GetCopy(fli, fpath);
                                }
                                break;
                            case "video":
                                if (newtype == "AVI" || newtype == "wma" || newtype == "rmvb" || newtype == "rm" || newtype == "flash" || newtype == "mp4" || newtype == "mid" || newtype == "3GP")
                                {
                                    GetCopy(fli, fpath);
                                }
                                break;
                            case "music":
                                if (newtype == "mp3" || newtype == "wma")
                                {
                                    GetCopy(fli, fpath);
                                }
                                break;
                            case "file":
                                if (newtype == "xls" || newtype == "xlsx" || newtype == "doc" || newtype == "docx" || newtype == "ppt" || newtype == "pptx" || newtype == "txt" || newtype == "pdf")
                                {
                                    GetCopy(fli, fpath);
                                }
                                break;
                        }
                        frm2.Increase(true);
                        frm.Close();
                        frm2.Show();
                    }
                    catch (Exception ex)
                    {
                        frm.Close();
                        MessageBox.Show(ex.Message);
                    }
                }
                bc.GetListViewItem(bc.Mpath(), FileType, imageList1, listView1);
                Clipboard.Clear();
            }
            else
            {
                frmProcessBar frm5 = new frmProcessBar();
                frmProcessBar frm6 = new frmProcessBar();
                if (T == 0)
                {
                    try
                    {
                        frm5.Increase(false);
                        frm5.Show();
                        for (int i = 0; i < al.Count; i++)
                        {
                            string name1 = al[i].ToString().Substring(al[i].ToString().LastIndexOf("\\") + 1, al[i].ToString().Length - al[i].ToString().LastIndexOf("\\") - 1);
                            string paths = bc.Mpath() + "\\" + name1;
                            if (File.Exists(al[i].ToString()))
                            {
                                if (al[i].ToString() != paths)
                                {
                                    File.Move(al[i].ToString(), paths);
                                }
                            }
                            if (Directory.Exists(al[i].ToString()))
                            {
                                bc.Files_Copy(paths, al[i].ToString());
                                DirectoryInfo di = new DirectoryInfo(al[i].ToString());
                                di.Delete(true);
                            }
                        }


                        frm6.Increase(true);
                        frm5.Close();
                        frm6.Show();
                        listView1.Items.Clear();
                        bc.GetListViewItem(bc.Mpath(), FileType, imageList1, listView1);//bc.GetListViewItem(bc.Mpath(), imageList1, listView1);
                    }
                    catch (Exception ex)
                    {
                        frm5.Close();
                        MessageBox.Show(ex.Message);
                    }


                }
                else
                {
                    try
                    {
                        frm5.Increase(false);
                        frm5.Show();
                        for (int i = 0; i < al.Count; i++)
                        {
                            string name1 = al[i].ToString().Substring(al[i].ToString().LastIndexOf("\\") + 1, al[i].ToString().Length - al[i].ToString().LastIndexOf("\\") - 1);
                            string paths = bc.Mpath() + "\\" + name1;
                            if (File.Exists(al[i].ToString()))
                            {
                                if (al[i].ToString() != paths)
                                {
                                    File.Copy(al[i].ToString(), paths, false);
                                }
                            }
                            if (Directory.Exists(al[i].ToString()))
                            {
                                bc.Files_Copy(paths, al[i].ToString());
                            }
                        }
                        frm6.Increase(true);
                        frm5.Close();
                        frm6.Show();
                        listView1.Items.Clear();
                        bc.GetListViewItem(bc.Mpath(), FileType, imageList1, listView1);//bc.GetListViewItem(bc.Mpath(), imageList1, listView1);
                    }
                    catch (Exception ex)
                    {
                        frm5.Close();
                        MessageBox.Show(ex.Message);
                    }
                }
            }
        }
        {
            int files = Clipboard.GetFileDropList().Count;


            frmProcessBar frm = new frmProcessBar();
            frmProcessBar frm2 = new frmProcessBar();




            if (files > 0)//电脑上的往V盘中复制
            {


                frm.Increase(false);
                frm.Show();
                for (int s = 0; s < files; s++)
                {
                    try
                    {
                        string fli = Clipboard.GetFileDropList()[s].ToString();
                        string fname = fli.Substring(fli.LastIndexOf("\\") + 1, fli.Length - fli.LastIndexOf("\\") - 1);
                        string fpath = bc.Mpath() + "\\" + fname;
                        string newtype = fli.Substring(fli.LastIndexOf(".") + 1, fli.Length - fli.LastIndexOf(".") - 1).ToLower();
                        if (fli.LastIndexOf(".") == -1)
                        {
                            if (Directory.Exists(newtype))
                            {
                                bc.Files_Copy(fpath, newtype);
                                //DirectoryInfo di = new DirectoryInfo(newtype);
                                //di.Delete(true);
                            }
                        }
                        switch (FileType)//先卡关类型
                        {
                            case "image":
                                if (newtype == "bmp" || newtype == "gif" || newtype == "png" || newtype == "jpg" || newtype == "jpeg" || newtype == "jpe")
                                {
                                    GetCopy(fli, fpath);
                                }
                                break;
                            case "video":
                                if (newtype == "AVI" || newtype == "wma" || newtype == "rmvb" || newtype == "rm" || newtype == "flash" || newtype == "mp4" || newtype == "mid" || newtype == "3GP")
                                {
                                    GetCopy(fli, fpath);
                                }
                                break;
                            case "music":
                                if (newtype == "mp3" || newtype == "wma")
                                {
                                    GetCopy(fli, fpath);
                                }
                                break;
                            case "file":
                                if (newtype == "xls" || newtype == "xlsx" || newtype == "doc" || newtype == "docx" || newtype == "ppt" || newtype == "pptx" || newtype == "txt" || newtype == "pdf")
                                {
                                    GetCopy(fli, fpath);
                                }
                                break;
                        }
                        frm2.Increase(true);
                        frm.Close();
                        frm2.Show();
                    }
                    catch (Exception ex)
                    {
                        frm.Close();
                        MessageBox.Show(ex.Message);
                    }
                }
                bc.GetListViewItem(bc.Mpath(), FileType, imageList1, listView1);
                Clipboard.Clear();
            }
            else
            {
                frmProcessBar frm5 = new frmProcessBar();
                frmProcessBar frm6 = new frmProcessBar();
                if (T == 0)
                {
                    try
                    {
                        frm5.Increase(false);
                        frm5.Show();
                        for (int i = 0; i < al.Count; i++)
                        {
                            string name1 = al[i].ToString().Substring(al[i].ToString().LastIndexOf("\\") + 1, al[i].ToString().Length - al[i].ToString().LastIndexOf("\\") - 1);
                            string paths = bc.Mpath() + "\\" + name1;
                            if (File.Exists(al[i].ToString()))
                            {
                                if (al[i].ToString() != paths)
                                {
                                    File.Move(al[i].ToString(), paths);
                                }
                            }
                            if (Directory.Exists(al[i].ToString()))
                            {
                                bc.Files_Copy(paths, al[i].ToString());
                                DirectoryInfo di = new DirectoryInfo(al[i].ToString());
                                di.Delete(true);
                            }
                        }


                        frm6.Increase(true);
                        frm5.Close();
                        frm6.Show();
                        listView1.Items.Clear();
                        bc.GetListViewItem(bc.Mpath(), FileType, imageList1, listView1);//bc.GetListViewItem(bc.Mpath(), imageList1, listView1);
                    }
                    catch (Exception ex)
                    {
                        frm5.Close();
                        MessageBox.Show(ex.Message);
                    }


                }
                else
                {
                    try
                    {
                        frm5.Increase(false);
                        frm5.Show();
                        for (int i = 0; i < al.Count; i++)
                        {
                            string name1 = al[i].ToString().Substring(al[i].ToString().LastIndexOf("\\") + 1, al[i].ToString().Length - al[i].ToString().LastIndexOf("\\") - 1);
                            string paths = bc.Mpath() + "\\" + name1;
                            if (File.Exists(al[i].ToString()))
                            {
                                if (al[i].ToString() != paths)
                                {
                                    File.Copy(al[i].ToString(), paths, false);
                                }
                            }
                            if (Directory.Exists(al[i].ToString()))
                            {
                                bc.Files_Copy(paths, al[i].ToString());
                            }
                        }
                        frm6.Increase(true);
                        frm5.Close();
                        frm6.Show();
                        listView1.Items.Clear();
                        bc.GetListViewItem(bc.Mpath(), FileType, imageList1, listView1);//bc.GetListViewItem(bc.Mpath(), imageList1, listView1);
                    }
                    catch (Exception ex)
                    {
                        frm5.Close();
                        MessageBox.Show(ex.Message);
                    }
                }
            }
        }

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值