4
Answers

how to split a string in C#

narasiman rao

narasiman rao

8y
472
1
 
  I am displaying all the project name in dropdownlist as follows

string sourceDirectory = Server.MapPath("~/");
DirectoryInfo directoryInfo = new DirectoryInfo(sourceDirectory);
var aspxFiles = new List(Directory.GetFiles(sourceDirectory, "*.aspx", SearchOption.AllDirectories));

foreach (string currentFile in aspxFiles)
{
this.ddllink.Items.Add(currentFile);
}

When i run in dropdownlist output as follows

E:Projects\Reception\Default.aspx


But i want in dropdownlist as follows Default.aspx

i want to split after \.

for that how can i do in asp.net using c#.

In dropdownlist i want output as follows
Default.aspx
 
Answers (4)