Basically i'm trying to get my program to copy a file from a location and send it over a series of ip addresses, i've commented each individual bit, but in short it just doesn't copy the file even tho it exists in the location
Public Class CopyPastFile
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
'this is only here so if you try to execute the copy command without a file selected it will alert you
If Textbox1.Text = "" Then
MsgBox("No file has been selected!")
Exit Sub
Else
End If
'this is creating the error log which will display wether the file was successfully copied to the machine or not
Dim path As String = "\\192.168.0.1\software\VB\errorlog.txt"
Dim fs As FileStream = File.Create(path)
Dim info As Byte() = New UTF8Encoding(True).GetBytes(urnstr & " " & ipstr)
fs.Write(info, 0, info.Length)
fs.Close()
' this goes through my database and selects each cell in a row and stores it tot he variable, which I then refer to
For rowIndex = 0 To DataGridView1.RowCount - 2
ipstr = DataGridView1.Rows(rowIndex).Cells(1).Value.ToString
urnstr = DataGridView1.Rows(rowIndex).Cells(0).Value.ToString
'MsgBox(urnstr & ipstr)
Try
'I think this is what is causing my error as I use a shell(xstr) command and it gives me a msgbox saying it was all good and my error log says successful but the file isn't transferred
with process.start it does the opposite and just says it cant find the file and the error log fails everything
xstr = ("xcopy " & fnstr & " " & ipstr & "\web /y")
Process.Start(xstr)
this writes all ip address as successful in the error log but only if the file is copied
My.Computer.FileSystem.WriteAllText("\\192.168.0.1\software\VB\errorlog.txt",
vbCrLf + urnstr & " " & ipstr & " " & " " & "Success", True)
Catch ex As Exception
MessageBox.Show("error ..." & ex.Message, "error")
'this does the opposite of the success and if it fails it lists it as a failure
My.Computer.FileSystem.WriteAllText("\\192.168.0.1\software\VB\errorlog.txt",
vbCrLf + urnstr & " " & ipstr & " " & " " & "Failed", True)
'this tells me if I am at the end of my datagrid view to cancel the loop
End Try
If rowIndex = DataGridView1.RowCount - 2 Then
Exit For
End If
Next
MessageBox.Show("Transfer Complete")
End Sub
Public Class CopyPastFile
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
'this is only here so if you try to execute the copy command without a file selected it will alert you
If Textbox1.Text = "" Then
MsgBox("No file has been selected!")
Exit Sub
Else
End If
'this is creating the error log which will display wether the file was successfully copied to the machine or not
Dim path As String = "\\192.168.0.1\software\VB\errorlog.txt"
Dim fs As FileStream = File.Create(path)
Dim info As Byte() = New UTF8Encoding(True).GetBytes(urnstr & " " & ipstr)
fs.Write(info, 0, info.Length)
fs.Close()
' this goes through my database and selects each cell in a row and stores it tot he variable, which I then refer to
For rowIndex = 0 To DataGridView1.RowCount - 2
ipstr = DataGridView1.Rows(rowIndex).Cells(1).Value.ToString
urnstr = DataGridView1.Rows(rowIndex).Cells(0).Value.ToString
'MsgBox(urnstr & ipstr)
Try
'I think this is what is causing my error as I use a shell(xstr) command and it gives me a msgbox saying it was all good and my error log says successful but the file isn't transferred
with process.start it does the opposite and just says it cant find the file and the error log fails everything
xstr = ("xcopy " & fnstr & " " & ipstr & "\web /y")
Process.Start(xstr)
this writes all ip address as successful in the error log but only if the file is copied
My.Computer.FileSystem.WriteAllText("\\192.168.0.1\software\VB\errorlog.txt",
vbCrLf + urnstr & " " & ipstr & " " & " " & "Success", True)
Catch ex As Exception
MessageBox.Show("error ..." & ex.Message, "error")
'this does the opposite of the success and if it fails it lists it as a failure
My.Computer.FileSystem.WriteAllText("\\192.168.0.1\software\VB\errorlog.txt",
vbCrLf + urnstr & " " & ipstr & " " & " " & "Failed", True)
'this tells me if I am at the end of my datagrid view to cancel the loop
End Try
If rowIndex = DataGridView1.RowCount - 2 Then
Exit For
End If
Next
MessageBox.Show("Transfer Complete")
End Sub