|
-
Aug 11th, 2012, 06:49 PM
#1
Thread Starter
Addicted Member
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?
-
Aug 11th, 2012, 06:56 PM
#2
Member
Re: Openfiledialog.filename is completely crazily wrong
Can you give me a source code of your project
-
Aug 11th, 2012, 07:19 PM
#3
Thread Starter
Addicted Member
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:
Select Case Locater.ShowDialog()
Case DialogResult.OK
If IO.File.Exists(Locate.FileName) Then
XML_Remove_Item(list:=list, address:=address, bMissing:=True)
'Grab the current user control UserList from the display panel
Dim ucList As UserList = DirectCast(MainForm.pnlList.Controls.Item(MainForm.pnlList.Controls.IndexOfKey("lView")), UserList)
'Create a new listviewitem to be displayed in ucList
Dim item As New ListViewItem
'Extract icon from file
Dim extractor As New IconExtractor
ucList.IM1.Images.Add(extractor.Extract(Locate.FileName, IconSize.Large))
'Set the text of the new listviewitem to be the name of the program
'without extension or path information
item.Text = IO.Path.GetFileNameWithoutExtension(Locate.FileName)
'Set the image index integer
item.ImageIndex = ucList.iImages
'set the tag to the file including path and extension
item.Tag = Locate.FileName
'Set the text to white
item.ForeColor = Color.White
'Add the item to ucList
ucList.lvList.Items.Add(item)
'Raise image index for later usage
ucList.iImages += 1
Write_Data_Item(list:=list, address:=Locate.FileName)
End If
Case DialogResult.Cancel
XML_Remove_Item(list:=list, address:=address, bMissing:=True)
End Select
-
Aug 11th, 2012, 07:29 PM
#4
Member
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)
-
Aug 11th, 2012, 07:39 PM
#5
Thread Starter
Addicted Member
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.
-
Aug 11th, 2012, 07:42 PM
#6
Member
Re: Openfiledialog.filename is completely crazily wrong
Ok well if you found your problem and fixed it I am glad.
-
Aug 11th, 2012, 07:56 PM
#7
Thread Starter
Addicted Member
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|