How can create variable If folder is empty files

Hi experts,

I have issue with write condition. for example
if folder have some excel files then delete all files
else continue process
how can i identify folders is empty or excel files?
could any one help me please?

Thanks
Abu

Hi @Abubakkar

Files=Directory.getFiles(InputFilePath)
and pass this into a string variable
and use path exists activity based on the condition do the manipulations

Thanks
Ashwin S

1 Like

@Abubakkar

  1. To check folder is empty use this in assign activity strarray =Directory.GetFiles(“directory path”)

If(strarray.count=0)
{
//Folder is empty
}

  1. To check excel file

For each item strarray
{

If(item.ToString.Contains(“xls”)
{
//delete excel
}
Else
{
// continue process
}

}

2 Likes

@Abubakkar Array.ForEach(Directory.GetFiles(@“c:\MyDir”), File.Delete);

1 Like

Thanks @aman_sheik
where can I apply it ? Assign activity or If condition?

@Abubakkar

Take Invoke Code Activity and in arguments create Argument(“String”)i.e., Your Path

in code write : Array.foreach(Directory.GetFiles(Path),Sub(x) File.Delete(x))

For your reference check below code

DeleFile_Ifexists.xaml (4.4 KB)

Hope this helps!!!

Thanks,
Aman Sheik.

1 Like

Thanks buddy .
how to copy excel files and paste another folder?
which activity should I use?
could you help me please

@Abubakkar

You can use copy file acivity

Thanks,
Aman Sheik.

1 Like

Thanks buddy @aman_sheik

1 Like

I got the error
“the target file directory is not a file”

Exception type : system.IO.IOException

@Abubakkar

Where you got this error in copy file Activity???

Yes buddy

i want to copy “macro excel” file and paste it another folder
that’s it

@Abubakkar

You have to give your source and destination path like this

Thanks
Aman sheik

1 Like