? vb.net亚博优惠活动之有关文件、文件夹操作的控件 亚博优惠活动,亚博体育网页版,亚博app怎么下载「官网直营」
VB.net 2010 视频亚博优惠活动 VB.net 2010 视频亚博优惠活动 VB.net 2010 视频亚博优惠活动
SQL Server 2008 视频亚博优惠活动 c#入门经典亚博优惠活动 Visual Basic从门到精通视频亚博优惠活动
  • vb.net亚博优惠活动之有关文件、文件夹操作的控件

  • 2015-01-18 15:16 来源:未知
有关文件、文件夹操作的控件?(相关vb.net亚博优惠活动)
文件操作是通过文件系统对象file directory来完成的,它可以完成文件(夹)的如下操作:创建、删除、复制、更名等。
复习通用对话框控件OpenFileDialog1及方法、属性:ShowDialog、FileName
(一)、File对象
命名空间:System.IO.File
作用:完成文件的创建、复制、移动、删除、打开等操作
常用方法:
Copy—复制文件
Create—创建新文件
Delete—删除文件
Move—移动文件
Open—打开文件,如果文件不存在,有创建功能。
Openread—打开文件并读出。
Openwrite—打开文件并写入。
应用实例:以文件的创建、复制、移动、删除为例来说一下文件操作的应用。[实验报告43]
程序见,file对象与文件操作
程序清单为:
Public Class Form1
??? Dim f As System.IO.File
??? Dim sourcename, desname As String
??? Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
??????? OpenFileDialog1.ShowDialog()
??????? sourcename = OpenFileDialog1.FileName
??????? TextBox1.Text = sourcename
??????? desname = InputBox("请输入目标文件名", "目标文件")
??????? f.Copy(sourcename, desname, True)
??????? TextBox2.Text = desname
??? End Sub
?
??? Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
??????? OpenFileDialog1.ShowDialog()
??????? sourcename = OpenFileDialog1.FileName
??????? TextBox1.Text = sourcename
? ??????f.Delete(sourcename)
??? End Sub
?
??? Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
??????? OpenFileDialog1.ShowDialog()
??????? sourcename = OpenFileDialog1.FileName
??????? TextBox1.Text = sourcename
??????? desname = InputBox("请输入要移动的目标文件名", "移动文件")
??????? f.Move(sourcename, desname)
??????? TextBox2.Text = desname
??? End Sub
?
??? Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
??????? desname = InputBox("请输入要新建的目标文件名", "新建文件")
??????? TextBox1.Text = desname
??????? f.Create(desname)
??? End Sub
?
??? Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
??????? desname = InputBox("请输入要打开的目标文件名", "打开文件")
??????? TextBox1.Text = desname
??????? f.Open(desname, IO.FileMode.Create, IO.FileAccess.Write)
End Sub
?
??? Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
?????? ?End
??? End Sub
?
End Class
相关亚博优惠活动