Showing posts with label BrowseFolder.ShowDialog. Show all posts
Showing posts with label BrowseFolder.ShowDialog. Show all posts

9/16/2013


Private Sub btn_Browse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Browse.Click
        

   Try
            Dim BrowseFolder As New FolderBrowserDialog
            BrowseFolder.ShowDialog()
            txt_FolderFile.Text = BrowseFolder.SelectedPath
            If txt_FolderFile.Text = "" Then
                Exit Sub
            End If

            System.Windows.Forms.Application.DoEvents()
            Cursor = Cursors.WaitCursor
            Dim dir As New DirectoryInfo(txt_FolderFile.Text)

            Dim aryFi As FileInfo() = dir.GetFiles("*.doc")
            Dim fi As FileInfo
            Dim i As Integer = 1

            For Each fi In aryFi
                Dim gFile As String = Path.GetFileNameWithoutExtension(fi.Name)
                ' process
            Next
   Catch ex As Exception
            MsgBox(ex.Message)

   End Try

End Sub

Posted on Monday, September 16, 2013 by nuyingnaja

8/21/2013

 ' Open File ShowDialog
    Public Function OpenFile(ByVal TypeFile As String)
        Dim _FileFull As String = ""
        Dim _typefile As String = ""

        If TypeFile = "pic" Then
            _typefile = "Picture Files (*.JPG)|*.JPG;"

        ElseIf TypeFile = "word" Then
            _typefile = "Office Documents (*.doc)|*.doc; "

        ElseIf TypeFile = "txt" Then
            _typefile = "text Documents (*.txt)|*.txt; "

        Else
            _typefile = "PDF File (*.pdf)|*.pdf"
        End If
        Try
            Dim dlg As OpenFileDialog = New OpenFileDialog()
            dlg.Filter = _typefile
            dlg.Title = "Open"
            If dlg.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
                _FileFull = dlg.FileName

                '=============================================
                If TypeFile = "pic" Then
                    Dim a As IO.FileInfo = New IO.FileInfo(_FileFull)
                    If a.Length > 20000 Then
                        Dim aaa = a.Length
                        MessageBox.Show("กรุณาเลือกไฟล์ขนาดไม่เกิน 200 KB")
                        OpenFile("pic")
                    End If
                End If

                '=============================================

            End If


        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
        Return _FileFull
    End Function

Posted on Wednesday, August 21, 2013 by nuyingnaja