how to save path value by split method

Posted by Priti2010 under ASP.NET on 8/1/2012 | Points: 10 | Views : 1024 | Status : [Member] | Replies : 3
how can i save only the last value of the path by split method
For eg: D:/Folder1/abc
OR
D:/Folder1/Folder2/abc

i need to save only "abc" as my value in string format where "abc" is my project name.

please help me how can i do this
i have try this method
string str1= "D:/Folder1/abc"
string[] split = str1.Split('/', ':');
for (int i = 0; i<split.Length; i++)
{

Response.Write(split[i].ToString());//Check here for getting the value..

}but its not working how can i save only the last value of the path

Thanks & Regards
Priti



Responses

Posted by: Ranjeet_8 on: 8/1/2012 [Member] [MVP] Gold | Points: 25

Up
0
Down
Hi priti.

Are u using File upload control ??

Priti2010, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Oswaldlily on: 8/1/2012 [Member] Starter | Points: 25

Up
0
Down
If u using fileupload,

go thru this
http://www.dotnetfunda.com/forums/thread8172-how-to-read-a-file-directly-without-including-in-project-appln.aspx

Priti2010, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ranjeet_8 on: 8/1/2012 [Member] [MVP] Gold | Points: 25

Up
0
Down
Hi... @priti

if u are using fileupload, try this.

string str = System.IO.Path.GetFileNameWithoutExtension(FileUpload1.PostedFile.FileName);


Priti2010, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response