MY Last folder name

In my drive three folder like folder 1,2,3 name. so in message box activity i need my last folder like 3 name.

like this type your last folder is " Folder name".

Hello @rAE_rAS ,

You can get using the below code.

if(Directory.GetFiles("FolderName").Length>0,Directory.GetFiles("FolderName")(Directory.GetFiles("FolderName").Length-1),"")

Thanks,
Sanjit

Where i put folder path?

instead of “FolderName” you can give the folder path

here which activity i will used ?

Hi @rAE_rAS ,

It also depends on the basis of which you want to retrieve the folder.
If you simply want to retrieve the last Folder, then you can use this inside of an Assign Activity:

Directory.GetDirectories(FolderPathGoesHere).Last()

If you want to retrieve the Folder which was last edited, then use this:

Directory.GetDirectories(FolderPathGoesHere).OrderBy(Function(o) New FileInfo(o).LastWriteTime).Last()

Kind Regards,
Ashwin A.K

Directory.GetDirectories(FolderPathGoesHere).Last() with this expression its show me folderpath with last folder but i only need last folder name not whole path.so which type i can do that

you have to use assign activity

use

Path.GetDirectoryName( path )

I need last folder name, but in expression show i think only name

use the below code to get the last folder name

Path.GetDirectoryName( Directory.GetDirectories(FolderPathGoesHere).Last())

its show folder path bro…i need only last folder name

use this and let me know

Path.GetDirectoryName(Directory.GetDirectories("C:\Users\...\Downloads\New folder").Last()).Split("\"c).LastOrDefault

Its show path last name not folder name
like is show New folder

try this

Path.GetDirectoryName(System.IO.Directory.GetDirectories("C:\Users\...\Desktop\Phase3","*", System.IO.SearchOption.AllDirectories).Last).Split("\"c).LastOrDefault

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.