将当前路径分配给变量 VB.net

Assigning current path to variable VB.net

我有个想法,但不知道如何实现。

Dim currentPath As String
    If System.IO.Path.Combine(Directory.GetCurrentDirectory(), "AccountServer.exe") OrElse System.IO.Path.Combine(Directory.GetCurrentDirectory(), "AccountServer.exe") Then

    End If

我想做的是让程序在当前文件中寻找AccountServer.exe,如果程序没有找到它,那么它会寻找AccountServer/AccountServer.exe.

如果找到该 .exe 的当前路径,则会将其分配给 currentPath 变量。

我将如何做到这一点,甚至可能吗?

您需要一些逻辑来查看文件是否存在:

        Dim currentPath As String = System.IO.Path.Combine(IO.Directory.GetCurrentDirectory(), "AccountServer.exe")
        If IO.File.Exists(currentPath) Then
            '...
        Else
            currentPath = System.IO.Path.Combine(IO.Directory.GetCurrentDirectory(), "AccountServer.exe")
            '...
        End If