Hiiiiiiii
i need the first characters of the string that is
ex:string str="testfolder/files/nagendra";
from the above string i need characters before first slash,that is "testfolder"
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
MahaPosted Nov 14, 2014, 7:14 AM
using System;
using System.Text.RegularExpressions;
class Program
{
static void Main()
{
string str = "testfolder/files/nagendra";
string[] x = Regex.Split(str, "/");
foreach (string n in x)
{
Console.WriteLine(n);
break;
}
Console.ReadKey();
}
}
/*
testfolder
*/
sudipta sanyalPosted Nov 14, 2014, 6:47 AM
Joginder BangerPosted Nov 14, 2014, 6:41 AM
string [] temp= str.split('/');
foreach(string firstvalue in temp)
{
str=firstvalue;
break;
}
Jaganathan BantheswaranPosted Nov 14, 2014, 6:39 AM
Try this.
string firstFolder = "testfolder/files/nagendra".Split("/")[0];