?
Solved

Why is my OpenFileDialog box soo slow on the desktop and how can I fix it?

Posted on 2006-06-20
3
Medium Priority
?
387 Views
Last Modified: 2010-04-23
I have a program where I open 3 files and save one.  The openfiledialog box should be pretty quick as with any other program, but when I tap the open file dialog button, it moves like a snail and the program almost freezes up.  Why is my program so slow when I try to open the OpenFileDialog box and point it towards the Desktop, but the speed for any other directory is a reasonable speed?  Here is my code for the form..see below.

Option Explicit On
Imports NIPreadandwrite.NIPGroupimportapp
Imports System
Imports System.IO


Public Class Form2

    Private Sub btnFileFind1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFileFind1.Click

        Dim strFileName As String
        Dim DidWork As Integer


        'OpenFD.InitialDirectory = "C:\PRU401k"

        OpenFD.Title = "Open a text file"
        OpenFD.Filter = "Text Files(*.txt)|*******R.txt"
        DidWork = OpenFD.ShowDialog()

        If DidWork = DialogResult.Cancel Then
            MsgBox("Cancel button clicked")
            Exit Sub
        Else
            strFileName = OpenFD.FileName
            'MsgBox(strFileName)
            TextBox1.Text = strFileName
        End If



    End Sub

    Private Sub btnFilefind2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFilefind2.Click

        Dim strFileName2 As String
        Dim DidWork2 As Integer


        'OpenFD2.InitialDirectory = "C:\PRU401k"

        OpenFD2.Title = "Open a text file"
        OpenFD2.Filter = "Text Files(*.txt)|*******L.txt"
        DidWork2 = OpenFD2.ShowDialog()

        If DidWork2 = DialogResult.Cancel Then
            MsgBox("Cancel button clicked")
            Exit Sub
        Else

            strFileName2 = OpenFD2.FileName
            'MsgBox(strFileName2)
            TextBox2.Text = strFileName2
        End If
    End Sub

    Private Sub btnFilefind3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFilefind3.Click

        Dim strFileName3 As String
        Dim DidWork3 As Integer

        'OpenFD3.InitialDirectory = "C:\PRU401k"
        OpenFD3.Title = "Open the CSV file"
        OpenFD3.Filter = "Text Files(*.csv)|*.csv"
        DidWork3 = OpenFD3.ShowDialog()

        If DidWork3 = DialogResult.Cancel Then
            MsgBox("Cancel button clicked")
            Exit Sub
        Else
            strFileName3 = OpenFD3.FileName
            ' MsgBox(strFileName3)
            TextBox3.Text = strFileName3
        End If
    End Sub

    Private Sub btnSaveFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSaveFile.Click

        Dim strFileName4 As String
        Dim DidWork4 As Integer


        SaveFD.Filter = "Text Files(*.txt)|*.txt"
        SaveFD.Title = "Save the output file"
        SaveFD.ShowDialog()

        If DidWork4 = DialogResult.Cancel Then
            MsgBox("Cancel button clicked")
            Exit Sub
        Else

            strFileName4 = SaveFD.FileName
            'MsgBox(strFileName4)
            TextBox4.Text = strFileName4
        End If

    End Sub

    Private Sub btnRun_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRun.Click

        If (TextBox1.Text.Length = 0 Or TextBox2.Text.Length = 0 Or TextBox3.Text.Length = 0 Or TextBox4.Text.Length = 0) Then
            MsgBox("Please fill all text boxes with a file path")
        Else
            ' Dim logdate As Date = Now()
            'Dim strdaterun As String
            'Dim strtimerun As String
            'Dim timenow As String

            Dim MyCmdargs(3) As String

            'strdaterun = logdate.Date.Year.ToString("0000") & logdate.Date.Month.ToString("00") & logdate.Date.Day.ToString("00")
            'strtimerun = logdate.Hour.ToString("00") & logdate.Minute.ToString("00") & logdate.Second.ToString("00")

            MyCmdargs(0) = TextBox1.Text
            MyCmdargs(1) = TextBox2.Text
            MyCmdargs(2) = TextBox3.Text
            MyCmdargs(3) = TextBox4.Text
            'MyCmdargs(4) = Path.GetFileNameWithoutExtension(TextBox4.Text & ".log")

            Dim c As New NIPGroupimportapp
            c.Main(MyCmdargs)
            Me.Hide()
            Form3.Show()
        End If




    End Sub

    Private Sub mnuOpen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuOpen.Click
        btnFileFind1.PerformClick()

    End Sub

    Private Sub OpenSecondtxtFileToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenSecondtxtFileToolStripMenuItem.Click
        btnFilefind2.PerformClick()

    End Sub

    Private Sub Open401kChartToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Open401kChartToolStripMenuItem.Click
        btnFilefind3.PerformClick()

    End Sub

    Private Sub btnDone_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDone.Click
        Me.Close()
        Application.Exit()

    End Sub

    Private Sub mnuExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuExit.Click
        btnDone.PerformClick()
    End Sub

    Private Sub mnuSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuSave.Click
        btnSaveFile.PerformClick()

    End Sub

    Private Sub ViewTextBoxesToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ViewTextBoxesToolStripMenuItem.Click
        System.Diagnostics.Process.Start(OpenFD.FileName)
    End Sub

    Private Sub mnuStrip_ItemClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolStripItemClickedEventArgs) Handles mnuStrip.ItemClicked

    End Sub
End Class
0
Comment
Question by:VBBRett
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 

Author Comment

by:VBBRett
ID: 16943504
Anyone?  Why is my program running so slow when I open it and point it towards the Desktop?
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 2000 total points
ID: 16945343
Is this 2005?

Bob
0
 

Author Comment

by:VBBRett
ID: 16945465
Yes, I figured it out Bob.  I set the .CheckFileExists property to False.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question