How to split windows directories path in C#

1 Answer

0 votes
using System;

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            string dir = @"D:\directx\ConsoleApplication_C_Sharp\bin";

            string[] parts = dir.Split('\\');
            foreach (string s in parts)
            {
                Console.WriteLine(s);
            }
        }
    }
}

/*
run:

D:
directx
ConsoleApplication_C_Sharp
bin

*/

 



answered Jan 24, 2017 by avibootz

Related questions

1 answer 267 views
1 answer 258 views
258 views asked Mar 9, 2017 by avibootz
1 answer 211 views
211 views asked Jan 14, 2017 by avibootz
1 answer 335 views
1 answer 280 views
280 views asked Aug 17, 2018 by avibootz
1 answer 227 views
1 answer 268 views
...