string [] userPath :  variable userPath, type string array  (size is
variable)
path is splitted with the seperator "\\"   -> in this case backslash

this means you have now in your array userPath all information from you path

e.g. C:\folder1\folder2\folder3\folder4\filename.txt

split with seperator backslash

--->
userpath[0] contains "C:"
 userpath[1] contains "folder1"
 userpath[2] contains "folder2"
 userpath[3] contains "folder3"
 userpath[4] contains "folder4"
 userpath[5] contains "filename.txt"

Now it looks like you wanna have only the last folder as a return value, so
without the filename

userPath.Length contains the number of fields in your array. In out case 6.
userPath[4] contains "folder4" what is your return value.

hopefully I explained it easiely enough.

michael

2010/2/22 Learner <[email protected]>

> Hi,
>
>  Can some one explain the below function
>
> public static string ExtractUserName(string path)
>    {
>        string[] userPath = path.Split(new char[] { '\\' });
>        return userPath[userPath.Length - 1];
>    }
>
> Thanks,
>
> L
>

Reply via email to