Click here to Skip to main content
15,885,925 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
D:\nageswararao\dec-14-12-night\Alumini_App\Alumini_App\Resume\NN_dd.doc

In the above path I need to find the last occurrence of '\' and from that I would like to divide the path in two two strings.
Posted
Updated 15-Dec-12 0:07am
v2
Comments
André Kraak 15-Dec-12 6:08am    
DO NOT SHOUT when asking a question. When you use all capital letters it is seen as shouting on the Internet and considered rude. Next time when posting a question please use proper capitalization.
ntitish 15-Dec-12 6:09am    
sorry, but i not mean that.............

You can use the Path class[^] for this.

Use the GetFullPath Method[^] to retrieve the path and GetFileName Method[^] for the file name.
Both links to the methods contain examples you can use.
 
Share this answer
 
Comments
Espen Harlinn 16-Dec-12 6:12am    
5'ed, as Path provides the required functionality :-D
C#
string a = @"D:\nageswararao\dec-14-12-night\Alumini_App\Alumini_App\Resume\NN_dd.doc";
int lastIndex = a.LastIndexOf('\\');
 
Share this answer
 
v2
Comments
Anuja Pawar Indore 17-Dec-12 0:57am    
Added code block
[no name] 17-Dec-12 7:09am    
I already posted same answer above :)
Hi,

Your solution:

C#
string strFilePath = @"D:\nageswararao\dec-14-12-night\Alumini_App\Alumini_App\Resume\NN_dd.doc";
MessageBox.Show( strFilePath.LastIndexOf('\\').ToString());
 
Share this answer
 
C#
string str = D:\nageswararao\dec-14-12-night\Alumini_App\Alumini_App\Resume\NN_dd.doc;   //will take input 
string[] strArr = new string[];
int count = 0;
char[] splitchar = { ' ' };
strArr = str.Split(splitchar);//here u will get each word in array index now decide what u have to do
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900