1

Utilities._Nameexeファイルから2つのレベルにあるディレクトリ(変数で名前が付けられた)を作成したいのですが、

私のexeファイルは、フルパスを使用せずに相対パスのみC:\SGEA\SGEA\bin を取得するにはどうすればよいですか?C:\SGEA\theNewDir

If Not System.IO.Directory.Exists(Utilities._Name) Then
   System.IO.Directory.CreateDirectory(Utilities._Name)
Else
   MessageBox.Show("There is already a dir named: " & Utilities._Name, "SGEA", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
4

1 に答える 1

1

exe ファイルへのパスがある場合は、System.IO.Path クラスを使用して簡単に移動できます。

Dim folder = Path.GetDirectoryName(theExeFile)
Dim grandparent = Path.GetDirectoryName(Path.GetDirectoryName(folder)) ' Up two directories

Dim newFolder = Path.Combine(grandparent, "theNewDir") ' Use this to create the new folder name cleanly

Utilities._Name = newFolder
于 2013-01-02T20:17:56.920 に答える