在拖拉事件中,怎么获取被拖拉文件的路径信息?

解决方案 »

  1.   


     void OnLocalListViewDrapDrop(object sender, DragEventArgs e)
            {
                try
                {
                    string[] formats = e.Data.GetFormats();                if (formats != null && formats.Length > 0)
                    {
                        foreach (string fmt in formats)
                        {
                            if (fmt == "FileNameW")
                            {
                                string[] fileNames = e.Data.GetData(fmt) as string[];
                                if (fileNames != null && fileNames.Length > 0)
                                {
                                    foreach (string fileName in fileNames)
                                    {
                                        if (!string.IsNullOrEmpty(fileName))
                                        {
                                            if (File.Exists(fileName))
                                            {
                                                FileSystem.CopyFile(fileName,
                                                                    Path.Combine(explorerTreeView.SelectedNode.Path,
                                                                                 Path.GetFileName(fileName)),
                                                                    UIOption.AllDialogs, UICancelOption.DoNothing);
                                            }
                                            if (Directory.Exists(fileName))
                                            {
                                                FileSystem.CopyDirectory(fileName, explorerTreeView.SelectedNode.Path,
                                                                         UIOption.AllDialogs, UICancelOption.DoNothing);
                                            }
                                        }
                                    }
                                    break;
                                }
                            }
                        }
                    }
                }
                catch
                {
                }
            }
      

  2.   

     FileSystem? 
    不懂?请教
      

  3.   

    就是1楼说的方法
    FileSystem是1楼封装的文件各种操作方法的类
    楼主可以按照1楼来做
      

  4.   


    using Microsoft.VisualBasic.FileIO;FileSystem是VB下的IO封装,比较强大