954,525 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Read specific text in c#

Hi Guys ,
I have a line which is like this :-
"C:\\Users\\saurabh\\Desktop\\Projects\\Texts\\A Sign of the Times.txt"
how can i jus extract the last part of it which is
A Sign of the Times.

Thanks

sdhawan
Junior Poster
122 posts since May 2010
Reputation Points: 8
Solved Threads: 0
 

Here pseudo code

Do streamreader untill null
{
    String readline = SreamLine;
}
MessageBox.Show(readline);
finito
Nearly a Posting Virtuoso
1,321 posts since May 2010
Reputation Points: 60
Solved Threads: 135
 

this is to reaqd the line.what i want to do is to get a substring froma sting.so if suppose i have string like C:\\Users\\saurabh\\Desktop\\Projects\\Texts\\A Sign of the Times.txt then i just want "A Sign of the Times" part of the string.Thanks for the help

sdhawan
Junior Poster
122 posts since May 2010
Reputation Points: 8
Solved Threads: 0
 

I got it guys .This is what i was suppose to do

int coll = names[currentFile].LastIndexOf(@"\");
                string sub = names[currentFile].Substring(coll + 1);
                int coll2 = sub.LastIndexOf(@".");
                string sub2 = sub.Remove(coll2);
                item.article = sub2;
sdhawan
Junior Poster
122 posts since May 2010
Reputation Points: 8
Solved Threads: 0
 

O sorry I see what happened.

finito
Nearly a Posting Virtuoso
1,321 posts since May 2010
Reputation Points: 60
Solved Threads: 135
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You