Creating directory that changes date

Dear all,

Currently i’m trying to create a directory that has the following path (N:\ABC\AB(Current date)\A)
the name of the directory should also be the (Current date)
For some reason it isn’t allowing me to use (Now.ToString(“yyyy.MM”).
Because the folder changes date every month i need to use something that also changes dates.


1 Like

i get a error when i use it
(“N:\VPs\Standard Reporting Package\DateTime.Now.ToString( “yyyy.MM”)\Support\Supporting Reports”)

Use like below -
“N:\VPs\Standard Reporting Package\" + DateTime.Now.ToString(“yyyy.MM”) + "\Support\Supporting Reports”

1 Like

Do i add DateTime.Now.ToString(“yyyy.MM”) at the end aswell
Because this:
“N:\VPs\Standard Reporting Package" + DateTime.Now.ToString(“yyyy.MM”) + "\Support\Supporting Reports”
is the path in wich the directory needs to be created

Yes, you can add. For example:

“N:\VPs\Standard Reporting Package\" + DateTime.Now.ToString(“yyyy.MM”)

because when i do this
(“N:\VPs\Standard Reporting Package”+DateTime.Now.ToString( “yyyy.MM”)+"\Support\Supporting Reports"+Now.ToString(“yyyy.MM”)")
it give me an error

"N:\VPs\Standard Reporting Package\”+DateTime.Now.ToString( “yyyy.MM”)+"\Support\Supporting Reports\"+ DateTime.Now.ToString(“yyyy.MM")

Thank you for the explanation the path doesnt show a error. However it isn’t creating a directory. Do you know why?

Make sure the root folder path is valid. Check if this location exists before creating -

N:\VPs\Standard Reporting Package\2019.01\Support\Supporting Reports\

Then you can use the following expression to create a folder -

"N:\VPs\Standard Reporting Package\”+DateTime.Now.ToString( “yyyy.MM”)+"\Support\Supporting Reports\"+ DateTime.Now.ToString(“yyyy.MM")

Try to print and check the file path is exist?

it does exsist

Try the below expression. In the previous expression ‘/’ was missing -

"N:\VPs\Standard Reporting Package\”+DateTime.Now.ToString(“yyyy.MM”)+"\Support\Supporting Reports\"+ DateTime.Now.ToString(“yyyy.MM")

1 Like

Thank you It worked!

1 Like

Can you mark the previous post as a solution.
Thank you.

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