2015-10-19 95 views
-1

我在這裏有一個想法,但我不知道如何實現它。指定變量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變量。

我該怎麼做,或者甚至有可能?

+0

'Path.Combine()'返回相結合,而不是結果....無論你是期待。打開選項嚴格 – Plutonix

回答

0

你需要一些邏輯來查看文件是否存在:

 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 
+0

這工作真棒,我只是想不出應該使用什麼代碼。謝謝! – Foxseiz