Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 8 of 8

Thread: Need help with FTP

  1. #1
    Junior Member
    Join Date
    Sep 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Need help with FTP

    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 a tag of my code
    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
    I'm going to be using a drop down menu giving the user a choice to FTP a batch or a single file...
    Plese help!!!


  2. #2
    Junior Member
    Join Date
    Sep 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Need help with FTP

    Sorry i posted this in the wrong forum. The code is VB.net

  3. #3
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Need help with FTP

    Thread moved from Members Introductions

  4. #4
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: Need help with FTP

    Does this posted code compile? Does it work and you just want to know how? What is the problem? What is your question? Post any error messages.

  5. #5
    Junior Member
    Join Date
    Sep 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Need help with FTP

    It is compiling but I'm trying to write FTP and don't know where to start

  6. #6
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: Need help with FTP

    I would say make a list of what you want to accomplish, spend some time with your favorite search engine. See if some code exists that can do what you are trying to get done. A forum (like this one) is more geared toward giving answers to specific questions and providing a nudge in the right direction. "...don't know where to start" pretty much leaves someone to have to adopt your project, figure out what you are trying to do, decide how to do it, and then help you get it done or just do it for you. That is the kind of help people charge for. (That kind of help is available through links on this site, but I do not do that)
    I think you can get back on track with a little research. Good luck

  7. #7
    Junior Member
    Join Date
    Sep 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Need help with FTP

    Thanks. Got it done, except it keeps saying the file i wanna FTP does not exist but i definitely does.

  8. #8
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: Need help with FTP

    Glad you got it done.
    Post questions/error messages if you can't get it to find the file