如何通过DRAG& DROP创建一个Windows应用程序来传输文件 [英] How to create a windows application to transfer file by DRAG&DROP

查看:69
本文介绍了如何通过DRAG& DROP创建一个Windows应用程序来传输文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I've been used a SAMBA FILE SERVER on a RASPBERRY PI as a media server for my home.
when I want to access or copy or move the file, I can handle it on my PC(windows 10) in normally network.So I want it to be more user friendly by make a simple application to transfer the file from my PC to raspberry pi by drag and drop. The example is perhaps 
we have MUSIC,VIDEO,PICTURE icons when we want to copy file just drag and drop to this icon and then copy to destination that we want 

Honestly I really don't have any experience with c# or visual basics 
so I need some advice about the basic knowledge,tutorial

thank you





我尝试了什么:



我试图研究c#语法和visual studio for basic知识。



What I have tried:

I tried to research c# syntax and visual studio for basic knowledge.

推荐答案

当使用Windows资源管理器作为源处理时,应用程序的删除控件非常简单。请参阅 C#简单拖放示例 [ ^ ]和从Windows资源管理器拖放文本文件到Windows窗体应用程序 [ ^ ]。



为放置目标控件实现类似的代码(显示的图标)或完整的表格(然后检查放置位置以确定哪个图标 - 如果有的话 - 发生掉落)。



在放置处理程序内创建通过从源pathes获取纯文件名来获取目标文件名( Path.GetFileName方法(字符串)(System.IO) [ ^ ])并将其附加到媒体特定目标路径(Pi共享)。然后使用 File.Copy方法复制文件(System.IO) [ ^ ]。



如果您没有(Windows)编程经验,则需要一些时间熟悉那个。然后我建议在尝试编写此应用程序之前花一些时间学习使用好书(首选)或在线教程。
When using the Windows Explorer as source handling the dropping on controls of your application is quite simple. See for example C# Simple drag and drop example[^] and Drag and Drop Text Files from Windows Explorer to your Windows Form Application[^].

Implement similar code for the drop target controls (the displayed icons) or the complete form (check then the drop location to determine over which icon - if any - the drop occured).

Inside the drop handler create the destination file names by getting the plain file name from the source pathes (Path.GetFileName Method (String) (System.IO)[^]) and append that to the media specific destination path (the Pi share). Then copy the files using the File.Copy Method (System.IO)[^].

If you don't have (Windows) programming experience it would take some time to become familiar with that. Then I suggest to invest some time in learning using a good book (preferred) or an online tutorial before trying to write this application.


这篇关于如何通过DRAG& DROP创建一个Windows应用程序来传输文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆