.Net Path Class Usage

ChangeExtension Changes the extension of a path string.

(C:\mydir\myfile.com.extension, .old)=> C:\mydir\myfile.com.old
(C:\mydir\myfile.com.extension, )=> C:\mydir\myfile.com.
(C:\mydir\, .old)=> C:\mydir\.old

Combine(String[]) Combines an array of strings into a path.

new[]{@"d:\archives", "2001", "media"} => d:\archives\2001\media

new[]{@"d:\archives", "2001", "\media"} => media (details)

Public methodStatic memberSupported by the XNA Framework
GetDirectoryName Returns the directory information for the specified path string.

C:\MyDir\MySubDir\myfile.ext => C:\MyDir\MySubDir

C:\ =>

Public methodStatic memberSupported by the XNA FrameworkGetExtension Returns the extension of the specified path string.

C:\mydir.old\myfile.ext => .ext

C:\mydir.old\ =>

Public methodStatic memberSupported by the XNA Framework
GetFileName Returns the file name and extension of the specified path string.

C:\mydir\myfile.ext => myfile.ext

C:\nydir =>

Public methodStatic memberSupported by the XNA Framework
GetFileNameWithoutExtension Returns the file name of the specified path string without the extension.

C:\mydir\myfile.ext => myfile

C:\mydir\ =>

Public methodStatic memberSupported by the XNA Framework
GetFullPath Returns the absolute path for the specified path string.

mydir => c:\temp\Demo\mydir [currentdir\mydir]

\mydir => c:\mydir

Public methodStatic memberGetInvalidFileNameChars Gets an array containing the characters that are not allowed in file names.Supported by the XNA Framework

Windows 7:

(",  0022) (<,  003C) (>,  003E) (|,  007C) (□,  0000) (□,  0001) (□,  0002) (□,  0003) (□,  0004) (□,  0005) (□,  0006) (□,  0007) (□,  0008) 0009 000A 000B 000C 000D (□,  000E) (□,  000F) (□,  0010) (□,  0011) (□,  0012) (□,  0013) (□,  0014) (□,  0015) (□,  0016) (□,  0017) (□,  0018) (□,  0019) (□,  001A) (□,  001B) (□,  001C) (□,  001D) (□,  001E) (□,  001F) (:,  003A) (*,  002A) (?,  003F) (\,  005C) (/,  002F)

GetInvalidPathChars Gets an array containing the characters that are not allowed in path names.

Windows 7:

Windows 7:

(",  0022) (<,  003C) (>,  003E) (|,  007C) (□,  0000) (□,  0001) (□,  0002) (□,  0003) (□,  0004) (□,  0005) (□,  0006) (□,  0007) (□,  0008) 0009 000A 000B 000C 000D (□,  000E) (□,  000F) (□,  0010) (□,  0011) (□,  0012) (□,  0013) (□,  0014) (□,  0015) (□,  0016) (□,  0017) (□,  0018) (□,  0019) (□,  001A) (□,  001B) (□,  001C) (□,  001D) (□,  001E) (□,  001F)

Public methodStatic memberSupported by the XNA Framework
GetPathRoot Gets the root directory information of the specified path.

\mydir\ => \

myfile.ext =>

c:\mydir\myfile.ext => c:\

Public methodStatic member
GetRandomFileName Returns a random folder name or file name

w143kxnu.idj

Public methodStatic member
GetTempFileName Creates a uniquely named, zero-byte temporary file on disk and returns the full path of that file.

This method creates a temporary file with a .TMP file extension. The temporary file is created within the user’s temporary folder, which is the path returned by the GetTempPath method.

Static member
GetTempPath Returns the path of the current user’s temporary folder.

This method checks for the existence of environment variables in the following order and uses the first path found:

  1. The path specified by the TMP environment variable.
  2. The path specified by the TEMP environment variable.
  3. The path specified by the USERPROFILE environment variable.
  4. The Windows directory.

Public methodStatic memberHasExtension Determines whether a path includes a file name extension.

myfile.ext => True

mydir\myfile => False

C:\myDir.ext\ => False

Public methodStatic memberSupported by the XNA Framework
IsPathRooted Gets a value indicating whether the specified path string contains a root.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s