DirectoryInfo.ToString DirectoryInfo.ToString DirectoryInfo.ToString DirectoryInfo.ToString Method

定義

傳回傳遞給 DirectoryInfo 建構函式的原始路徑。Returns the original path that was passed to the DirectoryInfo constructor. 使用 FullNameName 屬性作為完整路徑或檔案/目錄名稱,而不要使用這個方法。Use the FullName or Name properties for the full path or file/directory name instead of this method.

public:
 override System::String ^ ToString();
public override string ToString ();
override this.ToString : unit -> string
Public Overrides Function ToString () As String

傳回

使用者傳遞的原始路徑。The original path that was passed by the user.

備註

重要

ToString方法所傳回的字串代表傳遞給此DirectoryInfo函式的路徑。The string returned by the ToString method represents the path that was passed to the DirectoryInfo constructor. 根據您的意圖ToString ,您應該根據您的目的,抓取下列其中一個屬性的值,而不是呼叫方法:Instead of calling the ToString method, you should retrieve the value of either of the following properties, depending on your intent:

  • Name,以取得目錄的名稱,而不包含任何父路徑資訊。Name, to get the name of the directory, without any parent path information.
  • FullName,以取得目錄的完整路徑。FullName, to get the fully qualified path of the directory.

適用於

另請參閱