⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmfileoperation.frm

📁 VB6.0应用例题
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmFileOperation 
   Caption         =   "磁盘文件操作"
   ClientHeight    =   3915
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   5655
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   3915
   ScaleWidth      =   5655
   StartUpPosition =   3  '窗口缺省
   Begin VB.Frame Frame2 
      Caption         =   "目标"
      Height          =   1815
      Left            =   0
      TabIndex        =   5
      Top             =   2040
      Width           =   3975
      Begin VB.FileListBox File2 
         Height          =   990
         Left            =   2040
         TabIndex        =   11
         Top             =   600
         Width           =   1815
      End
      Begin VB.DirListBox Dir2 
         Height          =   990
         Left            =   120
         TabIndex        =   10
         Top             =   600
         Width           =   1935
      End
      Begin VB.DriveListBox Drive2 
         Height          =   315
         Left            =   120
         TabIndex        =   9
         Top             =   240
         Width           =   3735
      End
   End
   Begin VB.Frame Frame1 
      Caption         =   "源文件"
      Height          =   1815
      Left            =   0
      TabIndex        =   4
      Top             =   120
      Width           =   3975
      Begin VB.FileListBox File1 
         Height          =   990
         Left            =   1920
         TabIndex        =   8
         Top             =   720
         Width           =   1935
      End
      Begin VB.DirListBox Dir1 
         Height          =   990
         Left            =   120
         TabIndex        =   7
         Top             =   720
         Width           =   1815
      End
      Begin VB.DriveListBox Drive1 
         Height          =   315
         Left            =   240
         TabIndex        =   6
         Top             =   360
         Width           =   3615
      End
   End
   Begin VB.CommandButton cmdExit 
      Caption         =   "退出系统"
      Height          =   495
      Left            =   4200
      TabIndex        =   3
      Top             =   2760
      Width           =   1215
   End
   Begin VB.CommandButton cmdDel 
      Caption         =   "删除文件"
      Height          =   495
      Left            =   4200
      TabIndex        =   2
      Top             =   1920
      Width           =   1215
   End
   Begin VB.CommandButton cmdMove 
      Caption         =   "移动文件"
      Height          =   495
      Left            =   4200
      TabIndex        =   1
      Top             =   1200
      Width           =   1215
   End
   Begin VB.CommandButton cmdCopy 
      Caption         =   "复制文件"
      Height          =   495
      Left            =   4200
      TabIndex        =   0
      Top             =   480
      Width           =   1215
   End
End
Attribute VB_Name = "frmFileOperation"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub Drive1_Change()
  Dir1.Path = Drive1.Drive
  File1.Path = Dir1.Path
End Sub

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

Private Sub Drive2_Change()
  Dir2.Path = Drive2.Drive
  File2.Path = Dir2.Path
End Sub

Private Sub Dir2_Change()
  File2.Path = Dir2.Path
End Sub
Private Sub cmdCopy_Click()
  Dim I As Integer
  Dim FS As New FileSystemObject   '声明FS为FSO对象型变量
  Dim Dir1Path, Dir2Path As String
  If Right(Dir1.Path, 1) = "\" Then
     Dir1Path = Dir1.Path
  Else
     Dir1Path = Dir1.Path & "\"
  End If
  If Right(Dir2.Path, 1) = "\" Then
     Dir2Path = Dir2.Path
  Else
     Dir2Path = Dir2.Path & "\"
  End If
  For I = 0 To File1.ListCount - 1
     If File1.Selected(I) Then
        FS.CopyFile Dir1Path & File1.List(I), Dir2Path, True
        Dir2.Refresh
        File2.Refresh
     End If
  Next I
End Sub
Private Sub cmdMove_Click()
  Dim I As Integer
  Dim FS As New FileSystemObject
  Dim Dir1Path, Dir2Path As String
  If Right(Dir1.Path, 1) = "\" Then
     Dir1Path = Dir1.Path
  Else
     Dir1Path = Dir1.Path & "\"
  End If
  If Right(Dir2.Path, 1) = "\" Then
    Dir2Path = Dir2.Path
  Else
    Dir2Path = Dir2.Path & "\"
  End If
  For I = 0 To File1.ListCount - 1
    If File1.Selected(I) Then
        FS.MoveFile Dir1Path & File1.List(I), Dir2Path
        Dir2.Refresh
        File2.Refresh
    End If
  Next I
End Sub
Private Sub cmdDel_Click()
  Dim I As Integer
  For I = 0 To File1.ListCount - 1
     If File1.Selected(I) Then
        Kill Dir1.Path & "\" & File1.FileName
     End If
  Next I
  File1.Refresh
End Sub

Private Sub cmdExit_Click()
  Unload Me
End Sub





⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -