Counting number of folder present in server path

I am connected with a server and at particular path of the server there present number of folders how to count number of folder present.
if i using Directory.GetFiles(“”) and passing path as variable(because that path contains today’s date) it is giving error saying- The given path’s format is not supported.

thanks in advance

Is your variable having correct path
try to write it in write line and check whether it is ryt or not

yes, it has correct path

If I am doing it manually it is working fine. but while automating it is throwing error.


To count no. of folders inside parent folder try below expression.

       Int folderCount =  Directory.GetDirectories(“Folder Path”).Count

To count files.

    Int filesCount = Directory.GetFiles("parent FolderPath","*.*",SearchOption.AllDirectories).Count

The above expression will give you count of all files in the parent folder and it’s subfolders.

1 Like

But folder present on server and when i am passing server path with folder it is throwing error.

1 Like


kindly mention like this in GetFiles method
–first a assign activity like this
str_inputFilePath = “yourfolderpath”+“\”+Now.ToString(“dd/MM/yyyy”)
we can mention the date format as in your folder

–then another assign activity like this
int_filescount = Directory.GetFiles(str_inputFilePath.ToString).Count

Cheers @amit.chaudhary


Map that server path into your machine and then try once.

can you please explain this?

Is your studio is installed on server or your machine?

studio is installed in my machine.
what i need to do to get acess of the server in the same manner i can access my local machine.

Do you have access of those folders?