private void Form1_DragDrop(object sender, DragEventArgs e)
        {
            string fullPath = ((System.Array)e.Data.GetData(DataFormats.FileDrop)).GetValue(0).ToString();
            string filename = System.IO.Path.GetFileName(fullPath);//文件名  “Default.aspx”
            string extension = System.IO.Path.GetExtension(fullPath);//扩展名 “.aspx”
            string fileNameWithoutExtension = System.IO.Path.GetFileNameWithoutExtension(fullPath);// 没有扩展名的文件名 “Default”
            this.files.Text = fileNameWithoutExtension;
        }

        private void Form1_DragEnter(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(DataFormats.FileDrop))
            e.Effect = DragDropEffects.Link;
            else e.Effect = DragDropEffects.None;
        }

相关文章:

  • 2022-01-14
  • 2021-04-02
  • 2021-06-17
  • 2022-12-23
  • 2021-07-07
  • 2021-12-11
  • 2021-12-22
  • 2022-01-11
猜你喜欢
  • 2021-09-06
  • 2022-12-23
  • 2021-07-20
  • 2021-12-11
  • 2021-12-25
  • 2021-12-02
相关资源
相似解决方案