Results 1 to 3 of 3

Thread: [RESOLVED] [02/03] OpenFileDialog is locking the FileName folder

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2006
    Posts
    675

    Resolved [RESOLVED] [02/03] OpenFileDialog is locking the FileName folder

    Hello,
    I can break it down to this simple:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim f As New OpenFileDialog

    f.ShowDialog()
    f.Dispose()
    End Sub
    Say, I navigate the OpenFileDialog to my desktop, there is a folder called "Docs." At this point I can rename Docs, however, if I double-click Docs, I can no longer rename it. This makes sense to me. If, however, I select a file inside Docs, then Dispose of the OpenFileDialog, I still can't rename Docs. The only way that I can rename it is to either Exit the program entirely, OR I have found that I can click Button1 again. This opens another OpenFileDialog, I navigate to a different folder (or just hit back), and now I can rename Docs again.

    I have tried changing the .InitialDirectory and .FileName of the OFD after .ShowDialog, but it didn't work. Has anyone else encountered this problem? Does anyone have a solution?

    The problem comes because this is a multi user application and some people might leave it open all day, which could cause a folder to be locked for quite some time.
    VB.Net 2008
    .Net Framework 2.0

    "Must you breathe? 'Cause I need heaven..."

  2. #2
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: [02/03] OpenFileDialog is locking the FileName folder

    18,

    this should do it:

    Code:
            Dim f As New OpenFileDialog
            f.RestoreDirectory = True
            f.ShowDialog()
            f.Dispose()

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2006
    Posts
    675

    Re: [02/03] OpenFileDialog is locking the FileName folder

    Thank you. That is perfect.
    VB.Net 2008
    .Net Framework 2.0

    "Must you breathe? 'Cause I need heaven..."

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width