VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "comdlg32.ocx"
Begin VB.Form Form1 
   Caption         =   "文件复制与删除"
   ClientHeight    =   2370
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   4620
   LinkTopic       =   "Form1"
   ScaleHeight     =   2370
   ScaleWidth      =   4620
   StartUpPosition =   3  '窗口缺省
   Begin MSComDlg.CommonDialog CommonDialog1 
      Left            =   3285
      Top             =   555
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
   End
   Begin VB.CommandButton comDelFile 
      Caption         =   "删除文件"
      Height          =   495
      Left            =   3030
      TabIndex        =   2
      Top             =   1560
      Width           =   1050
   End
   Begin VB.CommandButton cmdCopy 
      Caption         =   "复制到..."
      Height          =   495
      Left            =   1635
      TabIndex        =   1
      Top             =   1545
      Width           =   1050
   End
   Begin VB.CommandButton cmdSelect 
      Caption         =   "选择文件"
      Height          =   510
      Left            =   240
      TabIndex        =   0
      Top             =   1515
      Width           =   1080
   End
   Begin VB.Label Label1 
      Caption         =   "Label1"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   960
      Left            =   375
      TabIndex        =   3
      Top             =   225
      Width           =   3795
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Dim strScr As String                        '定义模块变量存储源文件路径

Private Sub cmdCopy_Click()
    Dim strDes As String
    If strScr <> "" Then
        CommonDialog1.ShowSave              '打开“另存为”对话框
        strDes = CommonDialog1.FileName     '取得目标文件路径
        FileCopy strScr, strDes             '复制文件
        Label1.Caption = "文件" + strScr + "被复制到" + strDes
    Else
        MsgBox "请先选择源文件！"
    End If
End Sub

Private Sub cmdSelect_Click()
    CommonDialog1.ShowOpen                  '打开“打开”对话框
    strScr = CommonDialog1.FileName         '取得源文件路径
    Label1.Caption = "文件" + strScr + "已准备好！"
End Sub
Private Sub comDelFile_Click()
    '在确定源文件被选择后，弹出对话框要求再一次确定，当按下“确定”按钮时删除文件
    If strScr <> "" And MsgBox("确定要删除该文件！", vbYesNo) = vbYes Then
        Kill strScr                         '删除文件
        MsgBox strScr + "已经被删除！"
        strScr = ""                         '清空源文件路径
    End If
End Sub

Private Sub Form_Load()
    strScr = ""                             '源文件路径初始化
End Sub
