Results 1 to 7 of 7

Thread: Openfiledialog.filename is completely crazily wrong

Hybrid View

  1. #1
    Addicted Member EilaDoll's Avatar
    Join Date
    Dec 11
    Posts
    144

    Question Openfiledialog.filename is completely crazily wrong

    Ok, so here is one that is really making me dizzy. In my program, if a file has been moved, it asks if you want to locate it. If you say yes, then it brings up and openfiledialog named "Locate". When I use that find a file in, for example, my pictures, it finds the file and loads the correct string. However... if I use it to find a file in my desktop in a folder I called temp (I'm only using it for debugging) I get this:

    C:\Users\Alexis\AppData\Roaming\Microsoft\Installer\{33EBFC31-1223-4B94-8515-B485F5240EE5}\_2139E12AA18875AF9EC1D7.exe

    The file is named For You.lnk
    Location of the file is:
    C:\Users\Alexis\Desktop\Temp


    Anyone mind explaining what the hell just happened?
    http://www.vbforums.com/image.php?type=sigpic&userid=142423&dateline=1337150730

  2. #2
    Member
    Join Date
    Mar 11
    Posts
    44

    Re: Openfiledialog.filename is completely crazily wrong

    Can you give me a source code of your project

  3. #3
    Addicted Member EilaDoll's Avatar
    Join Date
    Dec 11
    Posts
    144

    Re: Openfiledialog.filename is completely crazily wrong

    All this part does is show the dialog and get the file name.
    But the file name is something way off in lala land. Odd part, the file it shows doesn't work on my 64 bit system, but the file that it's supposed to locate does.
    vb Code:
    1. Select Case Locater.ShowDialog()
    2.             Case DialogResult.OK
    3.                 If IO.File.Exists(Locate.FileName) Then
    4.                     XML_Remove_Item(list:=list, address:=address, bMissing:=True)
    5.  
    6.                     'Grab the current user control UserList from the display panel
    7.                     Dim ucList As UserList = DirectCast(MainForm.pnlList.Controls.Item(MainForm.pnlList.Controls.IndexOfKey("lView")), UserList)
    8.  
    9.                     'Create a new listviewitem to be displayed in ucList
    10.                     Dim item As New ListViewItem
    11.  
    12.                     'Extract icon from file
    13.                     Dim extractor As New IconExtractor
    14.                     ucList.IM1.Images.Add(extractor.Extract(Locate.FileName, IconSize.Large))
    15.  
    16.                     'Set the text of the new listviewitem to be the name of the program
    17.                     'without extension or path information
    18.                     item.Text = IO.Path.GetFileNameWithoutExtension(Locate.FileName)
    19.  
    20.                     'Set the image index integer
    21.                     item.ImageIndex = ucList.iImages
    22.  
    23.                     'set the tag to the file including path and extension
    24.                     item.Tag = Locate.FileName
    25.  
    26.                     'Set the text to white
    27.                     item.ForeColor = Color.White
    28.  
    29.                     'Add the item to ucList
    30.                     ucList.lvList.Items.Add(item)
    31.  
    32.                     'Raise image index for later usage
    33.                     ucList.iImages += 1
    34.  
    35.                     Write_Data_Item(list:=list, address:=Locate.FileName)
    36.                 End If
    37.             Case DialogResult.Cancel
    38.                 XML_Remove_Item(list:=list, address:=address, bMissing:=True)
    39.  
    40.         End Select
    http://www.vbforums.com/image.php?type=sigpic&userid=142423&dateline=1337150730

  4. #4
    Member
    Join Date
    Mar 11
    Posts
    44

    Re: Openfiledialog.filename is completely crazily wrong

    vb Code:
    Dim theFile As String = "C:\Users\Alexis\Desktop\Temp"

    If My.Computer.FileSystem.FileExists(theFile) = False Then
    MsgBox("File missing. Do you want to relocate the file?", vbOKCancel)
    If MsgBoxResult.Ok Then
    OpenFileDialog1.ShowDialog()
    theFile = OpenFileDialog1.FileName
    Else
    Exit Sub
    End If
    End If

    MsgBox(theFile)

  5. #5
    Addicted Member EilaDoll's Avatar
    Join Date
    Dec 11
    Posts
    144

    Re: Openfiledialog.filename is completely crazily wrong

    I was right about that so I just hell with it and wrote my own custom openfiledialog that wouldn't chase down target links. Working now, yay custom dialogs.
    http://www.vbforums.com/image.php?type=sigpic&userid=142423&dateline=1337150730

  6. #6
    Addicted Member EilaDoll's Avatar
    Join Date
    Dec 11
    Posts
    144

    Re: Openfiledialog.filename is completely crazily wrong

    The problem isn't the context in which I used the code as far as I can tell because I did the same thing on that.
    I show dialog, get file name, etc.
    The problem is the file name itself is turning up with some weird long string when I select the file. But it only does it for this one file.
    I think I discovered the issue though, the openfiledialog seems to think that when I say to grab a .lnk file then it automatically loops out to the target of that .lnk file.
    http://www.vbforums.com/image.php?type=sigpic&userid=142423&dateline=1337150730

  7. #7
    Member
    Join Date
    Mar 11
    Posts
    44

    Re: Openfiledialog.filename is completely crazily wrong

    Ok well if you found your problem and fixed it I am glad.

Posting Permissions

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