Click here to Skip to main content
Rate this: bad
good
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.6K
Edited 15-Dec-12 1:07am
v2
Comments
André Kraak at 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 at 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 at 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 at 17-Dec-12 0:57am
   
Added code block
MaulikDusara at 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
0 Maciej Los 495
1 Sergey Alexandrovich Kryukov 479
2 OriginalGriff 360
3 CHill60 280
4 CPallini 250
0 Sergey Alexandrovich Kryukov 10,102
1 OriginalGriff 9,495
2 Peter Leow 5,241
3 Kornfeld Eliyahu Peter 3,373
4 Maciej Los 3,076


Advertise | Privacy | Mobile
Web04 | 2.8.150327.1 | Last Updated 17 Dec 2012
Copyright © CodeProject, 1999-2015
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