|
-
Aug 8th, 2007, 06:57 AM
#1
Thread Starter
Lively Member
How to get folder name from url
hi
How to get folder name from url
like http:\\vinaykumar\Test\hllo.jpg
From this i need to get FolderName:Test
Please help me in this regard
Thanks
Vinay
-
Aug 8th, 2007, 08:58 AM
#2
Re: How to get folder name from url
Code:
string url = @"http:\\vinaykumar\Test\hllo.jpg";
string[] tmp = url.Split('\\');
MessageBox.Show(tmp[3]);
-
Aug 8th, 2007, 09:00 AM
#3
Thread Starter
Lively Member
Re: How to get folder name from url
Thnk u
got it
Thanks again
Regards
Vinay
-
Aug 8th, 2007, 07:58 PM
#4
Re: How to get folder name from url
You use the System.IO.Path class to manipulate file and folder paths:
C# Code:
string path = @"http://vinaykumar/Test/hllo.jpg";
string folder = Path.GetFileName(Path.GetDirectoryName(path));
Note that the names there may seem a little confusing but if you understand what each method does then it's clear. GetDirectoryName get's the fully qualified path less the part after the last delimiter, which may be a file or folder name. Thus GetDirectoryName returns @"http://vinaykumar/Test". GetFileName does the opposite: it gets ONLY the part after the last delimiter, which may or may not actually be a file name.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|