How to C# Path Class
C# provides effective ways of dealing with filenames and paths from its namespace System.IO . The Path Class performs operations on String instances that contain file or directory path information. The members of the Path class enable you to quickly and easily perform common operations such as returns filenae , extensios etc.
The following are the some important operations in C# Path Class:
GetDirectoryName - Returns the directory information for the specified path string.
GetExtension - Returns the extension of the specified path string.
GetFileName - Returns the file name and extension of the specified path string.
GetFileNameWithoutExtension - Returns the file name of the specified path string without the extension.
GetFullPath - Returns the absolute path for the specified path string.
Get Current Application Path
C# Class application in System.Windows.Forms namespace has static property called ExecutablePath . To get the current application path we can use GetDirectoryName of Path class with ExecutablePath as parameter.
applicationPath = Path.GetDirectoryName(Application.ExecutablePath)
It will return the current directory path of the .exe file .
- How to use C# Directory Class
- How to use C# File Class
- How to use C# FileStream Class
- How to use C# Textreader Class
- A simple C# Text Reader source code
- How to use C# TextWriter Class
- How to use C# BinaryWriter Class
- How to use C# BinaryReader Class
- How to convert XPS file to Bitmap
- How to create a pdf file in C#
- How to create PDF file from Text file
- Write Database data to pdf file