|
-
Jun 27th, 2002, 11:01 AM
#1
Thread Starter
Registered User
totally at a loss with openfiledialog extension
i have the following code
VB Code:
Dim myStream As System.IO.Stream
Dim openFileDialog1 As New OpenFileDialog()
openFileDialog1.Title = "Open a File"
openFileDialog1.InitialDirectory = "c:\"
openFileDialog1.Filter = "xml files (*.xml)|*.xml|All files (*.*)|*.*"
openFileDialog1.FilterIndex = 1
openFileDialog1.RestoreDirectory = True
If openFileDialog1.ShowDialog() = DialogResult.OK Then
myStream = openFileDialog1.OpenFile()
fileName = openFileDialog1.FileName
MsgBox(fileName)
If Not (myStream Is Nothing) Then
myStream.Close()
End If
End If
the thing that gets me, is that when i display the string name "filename" in the message box, it has two extension,
"test.xml.xml"
how can i only make it add one extension... I have no idea what is wrong..
thanks,
jeff
-
Jun 27th, 2002, 08:02 PM
#2
Frenzied Member
I dont know what you are doing wrong, cause I tried the code it worked ok.
BTW what do you have fileName declared as?
I declared it as a string and it worked perfect.
Hope that helped
-
Jun 28th, 2002, 01:58 AM
#3
Dazed Member
Did you name your files with the extension? I know that sounds stupid but if you name a text file Text.txt.txt you will get two extensions. I can't see either why your code would do that since the first part of the filter is just a description of the file type.
Try changing the first part of the filter just to see. ie......
Code:
OpenFileDialog.Filter = "TextFiles|*.txt|AllFiles| *.*|ExcelFiles|*.xls"
-
Jun 28th, 2002, 02:11 AM
#4
Could it be that you have set the option to hide extensions for known filetypes in explorer?
Maybe the file really is named test.xml.xml, and explorer hides the extension so it looks like it is named test.xml
-
Jun 28th, 2002, 06:11 AM
#5
Thread Starter
Registered User
i did name the file with two extensions, i must have not got enough sleep yesterday. the code works perfect...
thanks,
jeff
-
Jun 28th, 2002, 08:32 AM
#6
-
Jun 28th, 2002, 12:15 PM
#7
Dazed Member
-
Jul 10th, 2003, 08:26 PM
#8
Lively Member
Answered m own question. hahahaha
Last edited by Tenebrosity; Jul 10th, 2003 at 08:32 PM.
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
|