Click here to Skip to main content
15,887,746 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: Is there any way to eliminate the text based file *****.config Pin
Dave Kreskowiak17-Jun-16 10:19
mveDave Kreskowiak17-Jun-16 10:19 
GeneralRe: Is there any way to eliminate the text based file *****.config Pin
desanti17-Jun-16 11:05
desanti17-Jun-16 11:05 
GeneralRe: Is there any way to eliminate the text based file *****.config Pin
Dave Kreskowiak17-Jun-16 11:16
mveDave Kreskowiak17-Jun-16 11:16 
GeneralRe: Is there any way to eliminate the text based file *****.config Pin
Richard Deeming17-Jun-16 12:42
mveRichard Deeming17-Jun-16 12:42 
Questionproblem to convert stringbuilder to pdf 163 data but show only 162 Pin
mrprakash16-Jun-16 19:56
professionalmrprakash16-Jun-16 19:56 
AnswerRe: problem to convert stringbuilder to pdf 163 data but show only 162 Pin
CHill6016-Jun-16 22:19
mveCHill6016-Jun-16 22:19 
Questioncopy selected row from one gridview to another in VB.net when double click Pin
kishore-201616-Jun-16 15:52
kishore-201616-Jun-16 15:52 
Questionhow can i use one connection to upload multiple files in vb.net Pin
koriewhite16-Jun-16 4:31
koriewhite16-Jun-16 4:31 
i've this application that reads multiple files from a folder and upload them to the server..it works fine but when it wants to upload each file, it creates a connection, upload the file and closes the connection. it does the same thing for all the files over and over again. i want a situation where it creates just one connection, upload all the files and close the connection. please any help will be appreciated, i searched everywhere but couldnt find any help. below is my code

Imports System.IO
Imports System.Net

Public Class DemoFTPServerApp

Dim _Filename As String
Dim _UploadPath As String
Dim f As String


Public Sub LoadFiles(_User As String, _Password As String, _Path As String)
    Dim _MyArraylist As New ArrayList
    Dim FolderPath As String = "C:\Users\Desktop\files"



    Dim finfo As New DirectoryInfo(FolderPath)
    For Each fi In finfo.GetFiles("*.txt")
        _MyArraylist.Add(fi.FullName) 'full path only
        _Filename = fi.FullName
        f = fi.ToString()
        _UploadPath = _Path & f


       Try
      Dim request As FtpWebRequest = DirectCast(WebRequest.Create(New Uri(_UploadPath)), FtpWebRequest)
            request.Method = WebRequestMethods.Ftp.UploadFile
            request.Credentials = New NetworkCredential(_User, _Password)
            request.UseBinary = True
            request.UsePassive = False
            request.KeepAlive = True
            request.ConnectionGroupName = "company name"
            request.ServicePoint.ConnectionLimit = 4
            request.ServicePoint.CloseConnectionGroup("company name")


            Dim buffer(1023) As Byte
            Dim bytesIn As Long = 1

            Dim filepath As System.IO.FileInfo = New System.IO.FileInfo(_Filename)
            Dim _FileStream As System.IO.FileStream = filepath.OpenRead()
            Dim _Stream As System.IO.Stream = request.GetRequestStream


            Do Until bytesIn < 1
                bytesIn = _FileStream.Read(buffer, 0, 1024)
                If bytesIn > 0 Then
                    _Stream.Write(buffer, 0, bytesIn)

                End If
            Loop

            _Stream.Close()
            _Stream.Dispose()
            _FileStream.Close()
            _FileStream.Dispose()
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
    Next

    MessageBox.Show("File Succesfully uploaded!")

End Sub

Private Sub btnUploadFile_Click(sender As Object, e As EventArgs) Handles btnUploadFile.Click

   LoadFiles("username", "password", "ftp://ftpsite.com/")

End Sub

QuestionKeep database in program folder instead of default SQL server folder. Pin
desanti14-Jun-16 7:05
desanti14-Jun-16 7:05 
AnswerRe: Keep database in program folder instead of default SQL server folder. Pin
Eddy Vluggen14-Jun-16 7:14
professionalEddy Vluggen14-Jun-16 7:14 
GeneralRe: Keep database in program folder instead of default SQL server folder. Pin
desanti14-Jun-16 7:56
desanti14-Jun-16 7:56 
GeneralRe: Keep database in program folder instead of default SQL server folder. Pin
Eddy Vluggen14-Jun-16 8:26
professionalEddy Vluggen14-Jun-16 8:26 
AnswerRe: Keep database in program folder instead of default SQL server folder. Pin
Dave Kreskowiak14-Jun-16 7:34
mveDave Kreskowiak14-Jun-16 7:34 
GeneralRe: Keep database in program folder instead of default SQL server folder. Pin
desanti14-Jun-16 7:56
desanti14-Jun-16 7:56 
GeneralRe: Keep database in program folder instead of default SQL server folder. Pin
Dave Kreskowiak14-Jun-16 8:59
mveDave Kreskowiak14-Jun-16 8:59 
AnswerRe: Keep database in program folder instead of default SQL server folder. Pin
Gerry Schmitz16-Jun-16 8:01
mveGerry Schmitz16-Jun-16 8:01 
GeneralRe: Keep database in program folder instead of default SQL server folder. Pin
desanti18-Jun-16 8:12
desanti18-Jun-16 8:12 
GeneralRe: Keep database in program folder instead of default SQL server folder. Pin
Gerry Schmitz18-Jun-16 8:20
mveGerry Schmitz18-Jun-16 8:20 
GeneralRe: Keep database in program folder instead of default SQL server folder. Pin
desanti18-Jun-16 9:38
desanti18-Jun-16 9:38 
GeneralRe: Keep database in program folder instead of default SQL server folder. Pin
Mycroft Holmes18-Jun-16 13:32
professionalMycroft Holmes18-Jun-16 13:32 
GeneralRe: Keep database in program folder instead of default SQL server folder. Pin
desanti18-Jun-16 14:17
desanti18-Jun-16 14:17 
GeneralRe: Keep database in program folder instead of default SQL server folder. Pin
Mycroft Holmes18-Jun-16 16:48
professionalMycroft Holmes18-Jun-16 16:48 
QuestionUse a different dll for each project's form Pin
desanti14-Jun-16 2:50
desanti14-Jun-16 2:50 
AnswerRe: Use a different dll for each project's form Pin
Dave Kreskowiak14-Jun-16 4:21
mveDave Kreskowiak14-Jun-16 4:21 
GeneralRe: Use a different dll for each project's form Pin
desanti14-Jun-16 5:11
desanti14-Jun-16 5:11 

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.