フォルダ名とファイル名を結合して絶対パスを作成する Path.Combine
■フォルダ名とファイル名を結合して絶対パスを作成する Path.Combine
Path.Combineメソッドを使用する
Dim basePath As String = "C:\dir"
Dim filePath As String = "file.txt"
'2つのパスを結合する
Dim absolutePath As String = System.IO.Path.Combine(basePath, filePath)
'結果を表示する
Console.WriteLine(absolutePath)
' C:\dir\file.txt
'フォルダ名の後ろに"\"を付けてみる
basePath = basePath & "\"
'2つのパスを結合する
absolutePath = System.IO.Path.Combine(basePath, filePath)
'結果を表示する
Console.WriteLine(absolutePath)
' C:\dir\file.txt