Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# WinForm
Hi,
I have a string like this
C:\TEMP\FDB2\27JUN2012.TEL136430D\NDDF PLUS DB\NDDF Plus DB
and I want to extract a part from this like
27JUN2012.TEL136430D
. Plz Guide how can i do this ?
 
Thanks in advance
Posted 29-Jun-12 0:46am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You could use String.Split to break it into teh components:
string inp = "C:\TEMP\FDB2\27JUN2012.TEL136430D\NDDF PLUS DB\NDDF Plus DB"
string[] parts = inp.Split('\\');
Then it depends on how your paths will be organised: if it is always the third part you want, then
Console.WriteLine(parts[2]);
Will give it to you. Otherwise, you will have to look at each part and see f it matches whatever your criteria are. Without knowing more about the criteria, I can't say!
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Hi,
Go through this-
substring [^]
C# Strings[^]
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

string a= "C:\TEMP\FDB2\27JUN2012.TEL136430D\NDDF PLUS DB\NDDF Plus DB"
string[] a = comment.Split('\');
msgbox.show(a[2]);
  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 545
1 CPallini 490
2 George Jonsson 297
3 OriginalGriff 250
4 Suvabrata Roy 209
0 OriginalGriff 4,873
1 CPallini 3,900
2 Sergey Alexandrovich Kryukov 3,474
3 George Jonsson 2,646
4 Gihan Liyanage 2,236


Advertise | Privacy | Mobile
Web04 | 2.8.140905.1 | Last Updated 29 Jun 2012
Copyright © CodeProject, 1999-2014
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