FileOpen Directory Problem?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
I have A FileOpen command that opens A file outside of the local folder
(where my program is).
That works fine, but; I want to create a file in the local folder after that
1st file is opened, read, and closed. When I try

"FileOpen(3, "aircraft.lfc", OpenMode.Append)"

it automatically slaps the previous directory on the front of the file name.

How do I stop it from doing that, or what syntax do I use to return the
FilePath of the Local Folder (where my program is) as a String?
Thanks in advance,
Biggles
 
Public Function FindPath() As String
Dim temp As String =
System.Reflection.Assembly.GetExecutingAssembly.Location()
Dim a As Short
For a = Len(temp) To 1 Step -1
If Mid(temp, a, 1) = "\" Then
temp = Mid(temp, 1, a)
Return temp
End If
Next
End Function
 
Allen St.Clair said:
Public Function FindPath() As String
Dim temp As String =
System.Reflection.Assembly.GetExecutingAssembly.Location()
Dim a As Short
For a = Len(temp) To 1 Step -1
If Mid(temp, a, 1) = "\" Then
temp = Mid(temp, 1, a)
Return temp
End If
Next
End Function

A somewhat simpler and more efficient form (in C# so I don't make any
VB.NET syntax errors, but easy to translate):

public string FindPath()
{
string temp = Assembly.GetExecutingAssembly().Location;

int indexOfSlash = temp.IndexOf('\\');

if (indexOfSlash==-1)
{
return temp;
}
else
{
return temp.Substring (0, indexOfSlash);
}
}
 
Back
Top