Hi everyone,
I have trouble to get full path of a (*.txt) file
My code with open dialog box
===============================================================
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim myStream As Stream
Dim openFileDialog1 As New OpenFileDialog()
openFileDialog1.InitialDirectory = "%Userprofile%"
openFileDialog1.Filter = "Text files (*.txt)|*.txt"
openFileDialog1.FilterIndex = 1
openFileDialog1.RestoreDirectory = True
If openFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
myStream = openFileDialog1.OpenFile()
If Not (myStream Is Nothing) Then
' GetFullPath('myfile.txt')
Dim fileName As String = "myfile.txt" ////Also I don't want to get path of predefined files
Dim fullPath As String
fullPath = Path.GetFullPath(fileName)
'checking! file is in correct format
MsgBox(fullPath)
'close mystream
myStream.Close()
End If
End If
End Sub===================================================================
when i select a text file from desktop , it retrives path "C:\Users\Administrator\Documents\Visual Studio 2005\Projects\WindowsApplication1\WindowsApplication1\bin\Debug\(Name of text file)"
its mean this path from app.exe dir
Page 1 of 1
Visal Basic 2005 (get Full Path) How get full path of Text file
#2
Posted 15 November 2006 - 12:45 PM
Instead of:
Use:
If Not (myStream Is Nothing) Then
' GetFullPath('myfile.txt')
Dim fileName As String = "myfile.txt" ////Also I don't want to get path of predefined files
Dim fullPath As String
fullPath = Path.GetFullPath(fileName)
'checking! file is in correct format
MsgBox(fullPath)
'close mystream
myStream.Close()
End If
Use:
If Not (myStream Is Nothing) Then Dim fileName As String = openFileDialog1.Filename myStream.Close() End If
This post has been edited by jcarle: 15 November 2006 - 12:45 PM
- ← Batch file processing another batch + parameter
- Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
- [Help] VBscript gets info from text file →
Share this topic:
Page 1 of 1



Help

Back to top








