I have performed an activity to validate if a folder exists. If the folder does not exist, I would like it to create a folder called “Chargeback Letter” and I would like it to contain the previous business date(no weekends). Example: For 1/29/2024(a Monday). The folder should be labeled. “Chargeback Letter 1/26/2024.” My syntax is (“Chargeback Letters”+OutputFolderPath+DateTime.Today.AddDays(-1)). I get "disallow Date to string " error. I tried to convert with CDate and that didn’t work. I get alot of BC30512 data type conversion errors. I understand what the system is telling me, but do not know how to resolve. In some cases a CInt or other conversions work, but I need to understand how to avoid them entirely as a newbie Studio X developer. Any advice or article links to help me learn is appreciated.
Hey @kcaller
try this way:
NewBlankTask23.zip (49.8 KB)
Hi @kcaller
You can try the below way:
→ Use below both syntaxes in Set Variable Value.
previousBusinessDate= DateTime.Now.AddDays(-If(DateTime.Now.DayOfWeek = DayOfWeek.Monday, 3, 1)).ToString("MM_dd_yyyy")
folderName= "Chargeback Letter " + previousBusinessDate
→ Use Folder Exists activity and pass the below syntax:
Path.Combine("C:\",folderName)
Change the path within double quotes accordingly.
->Store the output in a variable say FolderExists
and use that variable in If condition:
If
FolderExists
Then
\\Do nothing
Else
Create Folder activity and give the below syntax:
Path.Combine("C:\",folderName)
End If
Check the below screenshot that while creating folders the below special characters aren’t allowed.

If you face any difficulties, I’m happy to help
Regards
1 Like