I'm writing a basic program for a company to capture POD files.
I am unable to figure out how the code works to FTP a file or a batch of files. The files are text files created by the program.
I have a default server for them to go to
Here is my code
I'm going to be using a drop down menu giving the user a choice to FTP a batch or a single file...
Please help!!
I am unable to figure out how the code works to FTP a file or a batch of files. The files are text files created by the program.
I have a default server for them to go to
Here is my code
VB.NET:
Imports System.Data.OleDb
Public Class Form1
Dim sw As IO.StreamWriter
Private Property ftpServer As Object
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim dt As Date = DateTimePicker1.Text
Dim tm As Date = DateTimePicker2.Text
Dim fm1 As String = "yyyyMMdd"
Dim fm2 As String = "HHmm"
Dim Awb As String = TextBox1.Text
Dim name As String = TextBox2.Text
Dim value As Integer = NumericUpDown1.Text
If Not System.IO.Directory.Exists("C:\POD") Then
System.IO.Directory.CreateDirectory("C:\POD")
End If
If IO.File.Exists("C:\POD\" & "podupl." & TextBox1.Text & ".txt") = False Then
sw = IO.File.CreateText("C:\POD\" & "podupl." & TextBox1.Text & ".txt")
sw.WriteLine("POD Upload")
sw.WriteLine(Awb & "|" & dt.ToString(fm1) & "|" & tm.ToString(fm2) & "|" & name & "|" & value)
TextBox1.Clear()
TextBox2.Clear()
NumericUpDown1.Value = 0
sw.WriteLine("END-OF-FILE")
sw.Close()
Label6.Text = "Captured successfully"
ElseIf IO.File.Exists("C:\POD\" & "podupl." & TextBox1.Text & ".txt") = True Then
Dim YesNo = MsgBox("Attention! POD already catured. Do you want to overwrite file?", vbYesNo)
Select Case YesNo
Case vbYes
sw = New IO.StreamWriter("C:\POD\" & "podupl." & TextBox1.Text & ".txt", False)
sw.WriteLine("POD Upload")
sw.WriteLine(Awb & "|" & dt.ToString(fm1) & "|" & tm.ToString(fm2) & "|" & name & "|" & value)
TextBox1.Clear()
TextBox2.Clear()
NumericUpDown1.Value = 0
Label6.Text = "Captured"
sw.WriteLine("END-OF-FILE")
sw.Close()
Label6.Text = "Overwrite successfull"
Case vbNo
Exit Sub
End Select
End If
Button1.Enabled = False
NumericUpDown1.Focus()
End Sub
Private Sub TextBox1_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.Enter
Label6.Text = ""
End Sub
Private Sub NumericUpDown1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NumericUpDown1.ValueChanged
If TextBox1.Text = "" And TextBox2.Text = "" And NumericUpDown1.Value < 1 Then
Button1.Enabled = False
Else
Button1.Enabled = True
End If
End Sub
Private Sub TextBox1_MouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TextBox1.MouseClick
Label6.Text = ""
End Sub
Private Sub ToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem1.Click
End Sub
End Class
Please help!!
Last edited: