string manipulation

E

Eugene Anthony

How do I retrieve part of a string "Car\Sports\mama.fla"

from:

"C:\My Documents\My Pictures\Car\Sports\mama.fla"


using asp.net 2.0 with c#.


Eugene Anthony
 
M

Mark Rae

How do I retrieve part of a string "Car\Sports\mama.fla"

from:

"C:\My Documents\My Pictures\Car\Sports\mama.fla"

using asp.net 2.0 with c#.

Will you always want to know "show me the relative path from the My Pictures
folder"...?
 
B

Bhaskardeep Khaund

Hi,


You need to first find the postion of the character which is constant for
you, like the folder name Car.....

then you can extract the substring from the main string starting from that
position to the end of the string......e.g:-

string str = "C:\\My Documents\\My Pictures\\Car\\Sports\\mama.fla";
Response.Write(str.Remove(str.IndexOf("Car"), str.Length));

Rgds,
Bhaskar
 
E

Eugene Anthony

This will be fixed:

"C:\My Documents\My Pictures\"

An this part will change:

Car\Sports\mama.fla"

Eugene Anthony
 
M

Mark Rae

This will be fixed:

"C:\My Documents\My Pictures\"

An this part will change:

Car\Sports\mama.fla"

string strFullPath = @"C:\My Documents\My Pictures\Car\Sports\mama.fla";
string strTrimPath = strFullPath.Replace("C:\\My Documents\\My Pictures\\",
String.Empty);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,772
Messages
2,569,593
Members
45,111
Latest member
KetoBurn
Top