file IO

Mortious

Member
Joined
Jul 7, 2003
Messages
5
Im going from VB6.0 to .NET and have a couple of questions.

My first one (and the only one Ill ask right now) is how do I handle flat text file IO. I have seen the examples below of this and those definatly help, but I dont want to hard code the path of the file.

In VB 6 I could use app.path with the rest of the file information to grab it, is there a .NET variance of app.path?

BTW I dont have the MSDN help libraries installed yet (waiting on the help desk guys to do that).

Thanks.
 
I use this class

This is the class I use to get the application path and also the exe name:


[VB]
Call it like so
Dim AppPath as New AppPath()

Here is the class
Public Class AppPath
Private mAppPath As String
Private mExeName As String

Public ReadOnly Property DirPath() As String
Get
Return mAppPath
End Get
End Property

Public ReadOnly Property ExeName() As String
Get
Return mExeName
End Get
End Property

Public Sub New()
Dim p As Path
Try
mAppPath = System.Reflection.Assembly.GetExecutingAssembly.Location
mExeName = Dir(mAppPath)
mAppPath = p.GetFullPath((Left(mAppPath, (Len(mAppPath) - Len(mExeName)))))
Catch
MsgBox(Err.Description, MsgBoxStyle.Critical, "Error!")
End Try
End Sub
End Class

Note: the path that is returned is to the "bin" directory in your project directory.
[/VB]
 
as mutant was saying Application.ExecutablePath , that returns the path and exe name all in 1 line :
Code:
MessageBox.Show(Application.ExecutablePath)

to get just the start up directory ( minus the exe name ) this works :
Code:
MessageBox.Show(Application.StartupPath)
 
Back
Top