文件知识大汇聚

本文详细介绍了如何通过代码实现文件路径管理、系统文件调用、文件复制与删除功能。重点阐述了在C、D、E、F盘间灵活穿梭的技巧,并展示了对特定文件类型的筛选与操作。通过调用Shell命令进行系统文件的调用,实现了对文件的高效管理和使用。此外,还提供了文件复制与删除的功能实现,确保了用户在文件操作过程中的便捷与安全性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

       我们每天点来点去,在C、D、E、F盘中来回的穿越。好像在找什么东西似的。开始以为文件很神秘,不知道奇怪的文件从何方而来,见证奇迹的时刻到来了。

埋头在文件中 - 李志鹏 - 李志鹏 廊坊师范学院信息提高班 第十期
 
对驱动、目录和文件列表框编写的代码如下。
 
Private Sub Command1_Click(Index As Integer)
    Select Case Index
        Case 0
            File1.Pattern = "*.*"
        Case 1
            File1.Pattern = "*.txt"
        Case 2
            File1.Pattern = "*.jpg;*.bmp;*.tif"
        Case 3
            File1.Pattern = "*.mp3;*.avi;*.wav;*.dat"
    End Select
End Sub
Private Sub Dir1_Change()
    File1.Path = Dir1.Path
End Sub
Private Sub Drive1_Change()
    Dir1.Path = Drive1.Drive
End Sub
Private Sub Form_Load()
    Dir1.Path = "c:\windows"
End Sub
 
埋头在文件中 - 李志鹏 - 李志鹏 廊坊师范学院信息提高班 第十期
  显示文件路径名
 
Private Sub Dir1_Change()
    File1.Path = Dir1.Path
    Label1.Caption = Dir1.Path
End Sub
Private Sub Drive1_Change()
    Dir1.Path = Drive1.Drive
    Label1.Caption = Drive1.Drive
End Sub
Private Sub File1_Click()
    If Right(Dir1.Path, 1) = "\" Then
        Label1.Caption = Dir1.Path & File1.FileName
    Else
        Label1.Caption = Dir1.Path & "\" & File1.FileName
    End If
End Sub
Private Sub Form_Load()
    Dir1.Path = Drive1.Drive
    File1.FileName = Dir1.Path
End Sub
 
调用系统文件
埋头在文件中 - 李志鹏 - 李志鹏 廊坊师范学院信息提高班 第十期
 
Private Sub Command1_Click(Index As Integer)
    Dim x
    Select Case Index
        Case 0
            x = Shell("D:\qq\QQProtect\Bin\QQProtect.exe", 1)
        Case 1
            x = Shell("D:\qq\QQProtect\Bin\QQProtect.exe", 3)
        Case 2
            x = Shell("D:\qq\QQProtect\Bin\QQProtect.exe", 3)
        Case 3
            x = Shell("D:\qq\QQProtect\Bin\QQProtect.exe", 1)
    End Select
End Sub


埋头在文件中 - 李志鹏 - 李志鹏 廊坊师范学院信息提高班 第十期
 
埋头在文件中 - 李志鹏 - 李志鹏 廊坊师范学院信息提高班 第十期
 
 

 
Private Sub Command1_Click()
    Dim killedfile As String, xuanzhe As String
    Dim x
    If Right(Dir1.Path, 1) = "\" Then
        xuanzhe = Dir1.Path & File1.FileName
    Else
        xuanzhe = Dir1.Path & "\" & File1.FileName
    End If
    killedfile = xuanzhe
    x = MsgBox("你确认你删除文件吗?", 35, "确认框")
        If x = 6 Then
        Kill killedfile
        MsgBox "确认已删除!"
    End If
End Sub

Private Sub Command2_Click()
    End
End Sub

Private Sub Dir1_Change()
    File1.Path = Dir1.Path
End Sub

Private Sub Drive1_Change()
    Dir1.Path = Drive1.Drive
End Sub

文件的复制

埋头在文件中 - 李志鹏 - 李志鹏 廊坊师范学院信息提高班 第十期

 

Private Sub Command1_Click()
    Dim yuanfile As String, mufile As String
    If Right(Dir1.Path, 1) = "\" Then
        yuanfile = Dir1.Path & File1.Path
    Else
        yuanfile = Dir1.Path & "\" & File1.Path
    End If
    mufile = InputBox("请输入要复制的目的文件", "请输入")
    If mufile <> "" Then
        FileCopy yuanfile, mufile
        MsgBox "复制成功"
    End If
    
End Sub

Private Sub Dir1_Change()
    File1.Path = Dir1.Path
End Sub

Private Sub Drive1_Change()
    Dir1.Path = Drive1.Drive
End Sub



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值