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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Jaganathan BantheswaranRank #170 · 14.1K reputationPosted Nov 14, 2014, 1:39 AM EST
Try this.
string firstFolder = "testfolder/files/nagendra".Split("/")[0];
Joginder BangerRank #360 · 7K reputationPosted Nov 14, 2014, 1:41 AM EST
string [] temp= str.split('/');
foreach(string firstvalue in temp)
{
str=firstvalue;
break;
}
sudipta sanyalRank #1,945 · 753 reputationPosted Nov 14, 2014, 1:47 AM EST
MahaRank #2,573 · 543 reputationPosted Nov 14, 2014, 2:14 AM EST
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
*/