c:\program files(x86)\company\application\
すべてのアプリ ファイルを含むフォルダーがあります。
のようなパスを取得するにはどうすればよいC:\program files(x86)\company
ですか?
Application.Startuppath
戻ってくるので使えませんc:\program files)x86)\company\application
。
ありがとう。
c:\program files(x86)\company\application\
すべてのアプリ ファイルを含むフォルダーがあります。
のようなパスを取得するにはどうすればよいC:\program files(x86)\company
ですか?
Application.Startuppath
戻ってくるので使えませんc:\program files)x86)\company\application
。
ありがとう。
使用するDirectory.GetParent(string path)
アプリにSystem.IO
名前空間 を含める
using System.IO;
と使用
string desired_path = Directory.GetParent(Application.StartupPath);
// will return c:\program files(x86)\company
// because app path will have c:\program files(x86)\company\application\
についてのこのMSDNコンテンツを参照してくださいSystem.IO.Path.GetDirectoryName(string)
だから、含める:
using System.IO;
今あなたのコード:
string ApplicationPath = Application.StartupPath;
string YourPath = Path.GetDirectoryName(ApplicationPath);
// This will get "C:\program files(x86)\company" from "C:\program files(x86)\company\application"
使用するのが最善でEnvironment.CurrentDirectory
あり、それはあなたを助けます。
http://msdn.microsoft.com/en-us/library/system.environment.currentdirectory%28v=vs.71%29.aspxを参照してください。
詳細については。