Click here to Skip to main content
16,016,345 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionVB.Net 'Subforms' Emulation/MS Access Pin
packerfan190416-Jun-06 5:48
packerfan190416-Jun-06 5:48 
AnswerRe: VB.Net 'Subforms' Emulation/MS Access Pin
Dave Kreskowiak18-Jun-06 2:36
mveDave Kreskowiak18-Jun-06 2:36 
QuestionRunning an external program but without knowledge of the location Pin
Marcus J. Smith16-Jun-06 5:03
professionalMarcus J. Smith16-Jun-06 5:03 
AnswerRe: Running an external program but without knowledge of the location Pin
Dave Kreskowiak18-Jun-06 2:31
mveDave Kreskowiak18-Jun-06 2:31 
GeneralRe: Running an external program but without knowledge of the location Pin
Marcus J. Smith22-Jun-06 3:58
professionalMarcus J. Smith22-Jun-06 3:58 
QuestionHTML Help Collections Integration Pin
lauralage16-Jun-06 4:58
lauralage16-Jun-06 4:58 
AnswerRe: '101' is not a valid value for 'value'. 'value' should be between 'minimum' and 'maximum' Pin
Guffa16-Jun-06 2:53
Guffa16-Jun-06 2:53 
GeneralRe: '101' is not a valid value for 'value'. 'value' should be between 'minimum' and 'maximum' [modified] Pin
CornElvis16-Jun-06 3:06
CornElvis16-Jun-06 3:06 
totally true, I have a progress bar.
this is the code I have:

Private Sub Form_Initialize()<br />
        InitCommonControls()<br />
    End Sub<br />
    Private Delegate Function CopyProgressRoutine(ByVal totalFileSize As Int64, ByVal totalBytesTransferred As Int64, ByVal streamSize As Int64, ByVal streamBytesTransferred As Int64, ByVal dwStreamNumber As Int32, ByVal dwCallbackReason As Int32, ByVal hSourceFile As Int32, ByVal hDestinationFile As Int32, ByVal lpData As Int32) As Int32<br />
<br />
    Private Declare Auto Function CopyFileEx Lib "kernel32.dll" (ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal lpProgressRoutine As CopyProgressRoutine, ByVal lpData As Int32, ByVal lpBool As Int32, ByVal dwCopyFlags As Int32) As Int32<br />
    Private _totalFileSize As Long = 0<br />
    Private _totalBytesCopied As Long = 0<br />
    Private _copyProgressRoutine As CopyProgressRoutine<br />
    Private Source, Source2, Source3, Source4 As String<br />
    Dim UserProfileName = SystemInformation.UserName<br />
<br />
<br />
    Private Destination As String = "H:\Documents and Settings\" & UserProfileName<br />
<br />
    Dim frmProgBar As New frmProgBar<br />
<br />
<br />
    Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click<br />
<br />
        Me.Close()<br />
        Dim fbdBrowse As New FolderBrowserDialog<br />
        If fbdBrowse.ShowDialog() = DialogResult.OK Then<br />
<br />
            Source = fbdBrowse.SelectedPath<br />
            Source2 = Source & "\" & "My Documents"<br />
            'Source3 = fbdBrowse.SelectedPath & "\Desktop"<br />
            'Source4 = fbdBrowse.SelectedPath & "\Favorites"<br />
        Else : End<br />
<br />
        End If<br />
<br />
        If (MessageBox.Show("You have chosen to copy all files and folders from: " & Chr(13) & Source & Chr(13) & "to: " & Chr(13) & Destination, "Data Mover", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1) = DialogResult.OK) Then<br />
<br />
<br />
            frmProgBar.Show()<br />
<br />
            GetTotalFileSize(New System.IO.DirectoryInfo(Source2))<br />
            _copyProgressRoutine = New CopyProgressRoutine(AddressOf CopyProgress)<br />
            CopyFiles(New System.IO.DirectoryInfo(Source), Destination)<br />
            MessageBox.Show("Data move done, make sure that the user doesn't have custom folders on d:\ or c:\", "Data Mover", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly)<br />
<br />
        Else<br />
            MessageBox.Show("Action Canceled", "Data Mover", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly)<br />
<br />
        End If<br />
<br />
<br />
        End<br />
<br />
    End Sub<br />
<br />
    Public Function CopyDirectory(ByVal Src As String, ByVal Dest As String, Optional _<br />
  ByVal bQuiet As Boolean = False) As Boolean<br />
        If Not Directory.Exists(Src) Then<br />
            Throw New DirectoryNotFoundException("The directory " & Src & " does not exists")<br />
        End If<br />
        If Directory.Exists(Dest) AndAlso Not bQuiet Then<br />
            If MessageBox.Show("directory " & Dest & " already exists." & vbCrLf & _<br />
             "If you continue, any files with the same name will be overwritten", _<br />
             "Continue?", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, _<br />
             MessageBoxDefaultButton.Button2) = DialogResult.Cancel Then Exit Function<br />
        End If<br />
<br />
        'add Directory Seperator Character (\) for the string concatenation shown later<br />
        'If Dest.Substring(Dest.Length - 1, 1) <> Path.DirectorySeparatorChar Then<br />
        '    Dest += Path.DirectorySeparatorChar<br />
        ' End If<br />
        If Not Directory.Exists(Dest) Then Directory.CreateDirectory(Dest)<br />
        Dim Files As String()<br />
        Files = Directory.GetFileSystemEntries(Src)<br />
        Dim element As String<br />
        For Each element In Files<br />
            If Directory.Exists(element) Then<br />
                'if the current FileSystemEntry is a directory,<br />
                'call this function recursively<br />
                CopyDirectory(element, Dest & Path.GetFileName(element), True)<br />
            Else<br />
                'the current FileSystemEntry is a file so just copy it<br />
                File.Copy(element, Dest & Path.GetFileName(element), True)<br />
            End If<br />
        Next<br />
        Return True<br />
    End Function<br />
    Private Function CopyProgress(ByVal totalFileSize As Int64, ByVal totalBytesTransferred As Int64, ByVal streamSize As Int64, ByVal streamBytesTransferred As Int64, ByVal dwStreamNumber As Int32, ByVal dwCallbackReason As Int32, ByVal hSourceFile As Int32, ByVal hDestinationFile As Int32, ByVal lpData As Int32) As Int32<br />
        frmProgBar.ProgressBar1.Value = Convert.ToInt32((_totalBytesCopied + totalBytesTransferred) / _totalFileSize * 100)<br />
        Application.DoEvents()<br />
    End Function<br />
    Private Sub GetTotalFileSize(ByVal folder As System.IO.DirectoryInfo)<br />
        For Each fi As System.IO.FileInfo In folder.GetFiles<br />
            _totalFileSize += fi.Length<br />
        Next<br />
        For Each di As System.IO.DirectoryInfo In folder.GetDirectories<br />
            GetTotalFileSize(di)<br />
        Next<br />
    End Sub<br />
    Private Sub CopyFiles(ByVal folder As System.IO.DirectoryInfo, ByVal destinationFolder As String)<br />
        If Not System.IO.Directory.Exists(destinationFolder) Then<br />
            System.IO.Directory.CreateDirectory(destinationFolder)<br />
        End If<br />
        For Each fi As System.IO.FileInfo In folder.GetFiles<br />
            CopyFileEx(fi.FullName, destinationFolder & "\" & fi.Name, _copyProgressRoutine, 0, 0, 0)<br />
            _totalBytesCopied += fi.Length<br />
        Next<br />
        For Each di As System.IO.DirectoryInfo In folder.GetDirectories<br />
            CopyFiles(di, di.FullName.Replace(Source, Destination))<br />
        Next<br />
    End Sub<br />
<br />
<br />
End Class


it's the value which is integer I guess and should be converted to something else.

thanks for the quick response btw.

Do you know what I'm doing wrong?

Greetzzz,

CornElvis
www.jackied.nl

-- modified at 9:25 Friday 16th June, 2006
GeneralRe: '101' is not a valid value for 'value'. 'value' should be between 'minimum' and 'maximum' Pin
Guffa16-Jun-06 4:58
Guffa16-Jun-06 4:58 
GeneralRe: '101' is not a valid value for 'value'. 'value' should be between 'minimum' and 'maximum' Pin
djo4ever21-Jun-06 0:45
djo4ever21-Jun-06 0:45 
GeneralRe: '101' is not a valid value for 'value'. 'value' should be between 'minimum' and 'maximum' Pin
Member 999003715-Apr-13 10:09
Member 999003715-Apr-13 10:09 
QuestionUnicode support for VB control Pin
kokatnur16-Jun-06 1:15
kokatnur16-Jun-06 1:15 
AnswerRe: Unicode support for VB control Pin
Dave Kreskowiak18-Jun-06 2:25
mveDave Kreskowiak18-Jun-06 2:25 
QuestionPing in VB.Net [modified] Pin
nitin_ion16-Jun-06 0:47
nitin_ion16-Jun-06 0:47 
AnswerRe: Ping in VB.Net Pin
Dave Kreskowiak16-Jun-06 1:53
mveDave Kreskowiak16-Jun-06 1:53 
QuestionDrag and drop applications in VB Pin
Kiran Pinjala16-Jun-06 0:43
Kiran Pinjala16-Jun-06 0:43 
AnswerRe: Drag and drop applications in VB Pin
Dave Kreskowiak16-Jun-06 1:51
mveDave Kreskowiak16-Jun-06 1:51 
Questionusing MSChart Pin
frisamkenya16-Jun-06 0:04
frisamkenya16-Jun-06 0:04 
AnswerRe: using MSChart Pin
Mekong River16-Jun-06 0:15
Mekong River16-Jun-06 0:15 
QuestionMDI Pin
Socheat.Net15-Jun-06 23:22
Socheat.Net15-Jun-06 23:22 
AnswerRe: MDI Pin
Mekong River16-Jun-06 4:16
Mekong River16-Jun-06 4:16 
QuestionWriting to the debug immediate window Pin
directred15-Jun-06 23:06
directred15-Jun-06 23:06 
AnswerRe: Writing to the debug immediate window Pin
Mekong River16-Jun-06 0:21
Mekong River16-Jun-06 0:21 
GeneralRe: Writing to the debug immediate window Pin
djo4ever21-Jun-06 0:48
djo4ever21-Jun-06 0:48 
GeneralRe: Writing to the debug immediate window Pin
Mekong River21-Jun-06 12:47
Mekong River21-Jun-06 12:47 

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.