
- C# Basic Tutorial
- C# - Home
- C# - Overview
- C# - Environment
- C# - Program Structure
- C# - Basic Syntax
- C# - Data Types
- C# - Type Conversion
- C# - Variables
- C# - Constants
- C# - Operators
- C# - Decision Making
- C# - Loops
- C# - Encapsulation
- C# - Methods
- C# - Nullables
- C# - Arrays
- C# - Strings
- C# - Structure
- C# - Enums
- C# - Classes
- C# - Inheritance
- C# - Polymorphism
- C# - Operator Overloading
- C# - Interfaces
- C# - Namespaces
- C# - Preprocessor Directives
- C# - Regular Expressions
- C# - Exception Handling
- C# - File I/O
- C# Advanced Tutorial
- C# - Attributes
- C# - Reflection
- C# - Properties
- C# - Indexers
- C# - Delegates
- C# - Events
- C# - Collections
- C# - Generics
- C# - Anonymous Methods
- C# - Unsafe Codes
- C# - Multithreading
- C# Useful Resources
- C# - Questions and Answers
- C# - Quick Guide
- C# - Useful Resources
- C# - Discussion
C# Program to split parts in a Windows directory
Firstly, set a string i.e. your Windows directory path −
string str = @"D:\Downloads\Amit";
Now use the Split() method and split wherever the \ occur −
str.Split(' \')
The following is the complete code −
Example
using System; class Program { static void Main() { string str = @"D:\Downloads\Amit"; Console.WriteLine("Directory...
"+str); string[] myStr = str.Split('\'); Console.WriteLine("
Split..."); foreach (string ch in myStr) { Console.WriteLine(ch); } } }
Output
Directory... D:\Downloads\Amit Split... D: Downloads Amit
- Related Articles
- Split a string in equal parts (grouper in Python)
- How to split a data frame in R into multiple parts randomly?
- Split string into equal parts JavaScript
- Where is MySQL bin directory located in Windows OS?
- How to break or split address into separated parts in Excel?
- How to find the MySQL data directory from command line in Windows?
- Golang Program to remove a specified directory
- Split the array into equal sum parts according to given conditions in C++
- Java program to List all files in a directory and nested sub-directory - Recursive approach
- Java Program to rename a file or directory
- Java program to List all files in a directory recursively
- Golang program to get all files present in a directory
- Java Program to split a string with dot
- C# Program to split a string on spaces
- Python program to split and join a string?

Advertisements