Click here to Skip to main content
15,890,186 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: How to compare 2 different text file lines and then process information if a match is in both file lines - Please help Pin
Richard MacCutchan25-Jan-17 5:57
mveRichard MacCutchan25-Jan-17 5:57 
GeneralRe: How to compare 2 different text file lines and then process information if a match is in both file lines - Please help Pin
Member 1186689324-Jan-17 9:11
Member 1186689324-Jan-17 9:11 
GeneralRe: How to compare 2 different text file lines and then process information if a match is in both file lines - Please help Pin
Eddy Vluggen25-Jan-17 6:21
professionalEddy Vluggen25-Jan-17 6:21 
QuestionHow to download all latest files from ftp server to pc automatically in vb.net Pin
Member 1295777522-Jan-17 15:38
Member 1295777522-Jan-17 15:38 
AnswerRe: How to download all latest files from ftp server to pc automatically in vb.net Pin
Michael_Davies22-Jan-17 20:43
Michael_Davies22-Jan-17 20:43 
GeneralRe: How to download all latest files from ftp server to pc automatically in vb.net Pin
Member 1295777522-Jan-17 21:09
Member 1295777522-Jan-17 21:09 
GeneralRe: How to download all latest files from ftp server to pc automatically in vb.net Pin
NotPolitcallyCorrect23-Jan-17 2:20
NotPolitcallyCorrect23-Jan-17 2:20 
QuestionHow to download all latest files from ftp server to pc automatically in vb.net Pin
Member 1295777522-Jan-17 15:07
Member 1295777522-Jan-17 15:07 
Hi folks,

I am new to vb. I need help to create a vb.net windows service to download latest new uploaded files from server after every 1 minute to local computer . This code download same only single file once the service started. BUT I want to windows service detect each latest new file uploaded on server and download it automatically.  Below is my code. Kindly help me.


Imports System
Imports System.IO
Imports System.Net
Imports System.Timers
Imports System.Threading

Public Class Service1


    Dim timerSchedule As System.Timers.Timer

    Protected Overrides Sub OnStart(ByVal args() As String)
        '  MyThread = New Threading.Thread(AddressOf Execute)

        timerSchedule = New System.Timers.Timer(1000)
        AddHandler timerSchedule.Elapsed, AddressOf timerSchedule_Elapsed
        timerSchedule.Start()

    End Sub


    Protected Overrides Sub OnStop()

    End Sub

    Private Sub timerSchedule_Elapsed(ByVal pSender As Object, ByVal pArgs As System.Timers.ElapsedEventArgs)
        Try
            timerSchedule.Stop()
            'call my a function to do the scheduled task

            FTPDownloadFile()
        Catch ex As Exception
        Finally
            timerSchedule.Start()
        End Try
    End Sub





    Private Sub FTPDownloadFile()

        Dim ftpuri As String = ""
        Dim downloadpath As String = ""
        Dim ftpusername As String = ""
        Dim ftppassword As String = ""

        'Create a WebClient.
        Dim request As New WebClient()

        ' Confirm the Network credentials based on the user name and password passed in.
        request.Credentials = New NetworkCredential("root", "")

        'Read the file data into a Byte array
        Dim bytes() As Byte = request.DownloadData("http://localhost/salary_system/")



        Try
            '  Create a FileStream to read the file into
            For Each i As String In downloadpath

                Dim DownloadStream As FileStream = IO.File.Create("C:\download\*.php")
                '  Stream this data into the file
                DownloadStream.Write(bytes, 0, bytes.Length)
                '  Close the FileStream
                DownloadStream.Close()
            Next

        Catch ex As Exception
            MsgBox(ex.Message)
            Exit Sub
        End Try

        MsgBox("Process Complete")

    End Sub



End Class

QuestionIsolating text within a text box Pin
Member 1296154621-Jan-17 13:27
Member 1296154621-Jan-17 13:27 
AnswerRe: Isolating text within a text box Pin
NotPolitcallyCorrect21-Jan-17 15:13
NotPolitcallyCorrect21-Jan-17 15:13 
Questionvb.net 2010 code check if values exist Pin
dcof19-Jan-17 12:00
dcof19-Jan-17 12:00 
AnswerRe: vb.net 2010 code check if values exist Pin
NotPolitcallyCorrect19-Jan-17 13:38
NotPolitcallyCorrect19-Jan-17 13:38 
AnswerRe: vb.net 2010 code check if values exist Pin
Richard Deeming20-Jan-17 2:04
mveRichard Deeming20-Jan-17 2:04 
Questionvb.net menu strip Pin
Member 1295543917-Jan-17 19:32
Member 1295543917-Jan-17 19:32 
QuestionRe: vb.net menu strip Pin
Richard MacCutchan17-Jan-17 22:23
mveRichard MacCutchan17-Jan-17 22:23 
AnswerRe: vb.net menu strip Pin
Dave Kreskowiak18-Jan-17 4:18
mveDave Kreskowiak18-Jan-17 4:18 
Questiondynamically generated custom class datagridview cellmousedoubleclick event Pin
Yiğit Sertaç Subaşı17-Jan-17 2:28
Yiğit Sertaç Subaşı17-Jan-17 2:28 
AnswerRe: dynamically generated custom class datagridview cellmousedoubleclick event Pin
Eddy Vluggen17-Jan-17 4:32
professionalEddy Vluggen17-Jan-17 4:32 
AnswerRe: dynamically generated custom class datagridview cellmousedoubleclick event Pin
Yiğit Sertaç Subaşı18-Jan-17 0:03
Yiğit Sertaç Subaşı18-Jan-17 0:03 
GeneralRe: dynamically generated custom class datagridview cellmousedoubleclick event Pin
Eddy Vluggen18-Jan-17 4:41
professionalEddy Vluggen18-Jan-17 4:41 
GeneralRe: dynamically generated custom class datagridview cellmousedoubleclick event Pin
Yiğit Sertaç Subaşı19-Jan-17 6:04
Yiğit Sertaç Subaşı19-Jan-17 6:04 
GeneralRe: dynamically generated custom class datagridview cellmousedoubleclick event Pin
Eddy Vluggen19-Jan-17 8:45
professionalEddy Vluggen19-Jan-17 8:45 
Question7 zip the folder part by part using vbscript Pin
Member 126754616-Jan-17 20:14
Member 126754616-Jan-17 20:14 
AnswerRe: 7 zip the folder part by part using vbscript Pin
Eddy Vluggen17-Jan-17 4:30
professionalEddy Vluggen17-Jan-17 4:30 
QuestionHow to embed Excel in web browser in vb .net Pin
Member 887818616-Jan-17 2:27
Member 887818616-Jan-17 2:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.