从列表框移动选定的文件 [英] Move selected files from Listbox

查看:58
本文介绍了从列表框移动选定的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我是一个新手,正在尝试编写我的第一个脚本.我成功地从列表框中的文件夹中填充了文件列表,但是我想使用列表框选择将选定的文件从一个文件夹移动到另一个文件夹.请帮我.谢谢
该脚本仅添加到列表中,而不能真正在文件夹内移动.

Hi all, I am a newbee and trying to write my first script. I successfully populated list of files from Folders in list boxes, but I want to move selected files from one folder to another using listbox selection. Please help me. Thanks
This script only adds to list, but not really moves inside folders.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim i As Integer
        i = ListBox1.SelectedItems.Count - 1
        Do While i >= 0

            ListBox2.Items.Add(ListBox1.SelectedItems.Item(i))

            ListBox1.Items.Remove(ListBox1.SelectedItems.Item(i))

            i = i - 1

        Loop
    End Sub


<pre lang="vb">

推荐答案

您可以使用File.Move移动文件.
http://msdn.microsoft.com/en-us/library/system.io. file.aspx [^ ]
You can use File.Move to move files.
http://msdn.microsoft.com/en-us/library/system.io.file.aspx[^]


这篇关于从列表框移动选定的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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