Click here to Skip to main content
12,622,032 members (32,411 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: ASP.NET
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 15-Dec-12 1:03am
ntitish1.9K
Updated 15-Dec-12 1: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.............
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
Comments
Espen Harlinn 16-Dec-12 6:12am
   
5'ed, as Path provides the required functionality :-D
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 5

string a = @"D:\nageswararao\dec-14-12-night\Alumini_App\Alumini_App\Resume\NN_dd.doc";
int lastIndex = a.LastIndexOf('\\');
  Permalink  
v2
Comments
Anuja Pawar Indore 17-Dec-12 0:57am
   
Added code block
MaulikDusara 17-Dec-12 7:09am
   
I already posted same answer above :)
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 4

Hi,

Your solution:

string strFilePath = @"D:\nageswararao\dec-14-12-night\Alumini_App\Alumini_App\Resume\NN_dd.doc";
MessageBox.Show( strFilePath.LastIndexOf('\\').ToString());
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

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
  Permalink  
v2

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.161128.1 | Last Updated 17 Dec 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100