예제 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void  时ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string mainpath = AlarmSystemHelper.GetValueByIni("Main", "MainCatalog");

            mainpath = System.Web.HttpUtility.UrlDecode(mainpath, System.Text.Encoding.Unicode);
            System.Diagnostics.Process.Start(mainpath);
        }
예제 #2
0
        /// <summary>
        /// 松开后
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Main_DragDrop(object sender, DragEventArgs e)
        {
            try
            {
                //获取主目录位置
                string mainpath = AlarmSystemHelper.GetValueByIni("Main", "MainCatalog");
                mainpath = System.Web.HttpUtility.UrlDecode(mainpath, System.Text.Encoding.Unicode); //编码
                                                                                                     //GetValue(0) 为第1个文件全路径
                                                                                                     //DataFormats 数据的格式,下有多个静态属性都为string型,除FileDrop格式外还有Bitmap,Text,WaveAudio等格式
                List <string> pathList = new List <string>();
                for (int i = 0, len = ((System.Array)e.Data.GetData(DataFormats.FileDrop)).Length; i < len; i++)
                {
                    string path = ((System.Array)e.Data.GetData(DataFormats.FileDrop)).GetValue(i).ToString();
                    pathList.Add(path);
                    Console.WriteLine(i + path);
                }

                foreach (var item in pathList)
                {
                    if (System.IO.Directory.Exists(item))
                    {
                        MessageBox.Show("暂不支持文件夹分类");
                        //文件夹
                        // FileHelper.DoCopy(item, "F:\\c\\llp.iso");
                    }
                    else if (System.IO.File.Exists(item))
                    {
                        //获取扩展名 “.aspx”
                        string extension = System.IO.Path.GetExtension(item).TrimStart('.');

                        //根据扩展名生成文件夹
                        var dicnmae = XmlHelper.SelectFromXml(System.AppDomain.CurrentDomain.BaseDirectory + "fsdata.xml", "rules", "formattype", "formatname", extension).Item2;
                        if (string.IsNullOrWhiteSpace(dicnmae))
                        {
                            dicnmae = "其他";
                        }
                        string newPath = mainpath + $"\\{dicnmae}"; //合成新文件夹路径
                                                                    //判断是否存在新文件路径 不存在创建
                        if (!System.IO.Directory.Exists(newPath))
                        {
                            Directory.CreateDirectory(newPath);//创建该文件
                        }
                        // 获取文件名
                        string filename = System.IO.Path.GetFileName(item);//文件名  “Default.aspx”
                        newPath     = newPath + $"\\{filename}";
                        label1.Text = "复制中···";
                        FileHelper.FileCopyTo(item, newPath, true);
                        label1.Text = string.Empty;
                        newPath     = string.Empty;
                    }
                }
                this.label1.Cursor = System.Windows.Forms.Cursors.IBeam; //还原鼠标形状
                button1.Visible    = false;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }