主题:如何把C:\CARD\BACKUP里面的文件移动到D:\BACKUP中??在线等
海上土拨鼠
[专家分:60] 发布于 2005-10-21 10:14:00
请问:
如何在这段代码之后把C:\CARD\BACKUP里面的文件移动到D:\BACKUP呢?
请教高手代码!!!!!急急急
回复列表 (共3个回复)
沙发
海上土拨鼠 [专家分:60] 发布于 2005-10-21 10:15:00
代码如下:
Private Sub MenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem2.Click
Try
Dim row1 As DataRow
Dim DS As New DataSet
Dim myStream As Stream
Dim GH As String
Dim openFileDialog1 As New OpenFileDialog
openFileDialog1.InitialDirectory = "c:\CARD\BACKUP\"
openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"
openFileDialog1.FilterIndex = 2
openFileDialog1.RestoreDirectory = True
If openFileDialog1.ShowDialog() = DialogResult.OK Then
myStream = openFileDialog1.OpenFile()
If Not (myStream Is Nothing) Then
Dim objreader As StreamReader = New StreamReader(myStream)
Dim x As String
If myCon.State = ConnectionState.Closed Then
myCon.Open()
End If
While objreader.Peek <> -1
Label1.Visible = True
x = objreader.ReadLine
'把工号与卡号关联起来
myCmd.CommandText = "SELECT EMPL_ID FROM EMPLOYEE WHERE (card_id = N'" & x.Substring(0, 10) & "')"
myCmd.Connection = myCon
myCmd.ExecuteNonQuery()
MyDa.SelectCommand = myCmd
MyDa.Fill(DS)
Console.WriteLine(DS.Tables(0).Rows.Count)
If DS.Tables(0).Rows.Count > 0 Then
For Each row1 In DS.Tables(0).Rows
GH = row1!EMPL_ID & ""
Next
DS.Clear()
End If
'把采集的数据放到SQL数据库中
myCmd.CommandText = "INSERT INTO CLOCK_CARD(card_no_new, card_date_time, card_clock, card_flag, empl_id) " & _
" VALUES (N'" & x.Substring(0, 10) & "', '" & x.Substring(13, 4) & "-" & x.Substring(17, 2) & "-" & x.Substring(19, 2) & " " & _
x.Substring(21, 2) & ":" & x.Substring(23, 2) & ":" & x.Substring(25, 2) & "', N'" & x.Substring(28, 3) & "', N'" & x.Substring(32, 1) & "', N'" & GH & "')"
Console.WriteLine(myCmd.CommandText)
myCmd.Connection = myCon
myCmd.ExecuteNonQuery()
MyDa.SelectCommand = myCmd
End While
objreader.Close()
objreader = Nothing
myStream.Close()
End If
MsgBox("资料处理完毕……!")
End If
Catch ex As Exception
MessageBox.Show(Err.Description & ex.ToString)
End Try
板凳
ryowu [专家分:6470] 发布于 2005-10-21 13:04:00
Directory类里面有的吧,copy方法
3 楼
海上土拨鼠 [专家分:60] 发布于 2005-10-21 14:00:00
我要用MOVE方法直接剪切过去
我来回复