VB.net 2010 视频教程 VB.net 2010 视频教程 python基础视频教程
SQL Server 2008 视频教程 c#入门经典教程 Visual Basic从门到精通视频教程
当前位置:
首页 > 编程开发 > 批处理教程 >
  • vb.net教程之directory对象

directory对象(相关vb.net教程)
作用:完成文件夹的创建、删除等操作。
命名空间:system.io.directory
常用方法:
CreateDirectory:创建
Delete:删除
Move:移动
应用实例:文件夹的创建、删除、移动(同盘内)操作。程序见,directory对象及操作[实验报告44]
程序为:
Public Class Form1
    Dim s, ss As String
    Dim d As System.IO.Directory
 
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        s = InputBox("请输入要创建的文件夹", "目标文件夹")
        TextBox1.Text = s
        d.CreateDirectory(s)
    End Sub
 
       Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        s = InputBox("请输入要删除的文件夹", "删除文件夹")
        TextBox1.Text = s
        d.Delete(s)
    End Sub
 
    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        s = InputBox("请输入要移动的文件夹", "源文件夹")
        TextBox1.Text = s
        ss = InputBox("请输入要移动到的目标文件夹", "目标文件夹")
        TextBox2.Text = ss
        d.Move(s, ss)
    End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        End
    End Sub
End Class


相关教程