Create a file with the current date and time in the name

Hello,

I am trying to make a program, which creates .csv files using the same process but with different information. Because so far, every time when I run the program, it overrides the previous .csv file, I need to add date/time in the file name in order to create different .csv’s every run.

I have tried to create a variable with: System.DateTime.Now.ToString() and then add it to the file path/name but no success so far. Not sure how to proceed with the file path/name syntax.

Any ideas would be greatly appreciated!

1 Like

Attach your xaml file here.

1 Like

https://ufile.io/oh3xd

I am sorry for the link, but I cannot upload files since I am a new user.

1 Like

Try This:
Path.Combine(FolderPathVar, “Test”+Now.ToString(“yyMMdd.hhmmss”)+".csv")

1 Like

While adding System.DateTime.Now.ToString() to path make sure you are adding expected file extension as well.

And check the property create new in CSV activities

Hello again! Thanks!

It worked! The only catch was to properly create the path variable, for which I used the expression:
path.GetFullPath("D:\uipath".ToString)

path.Combine(folderpath.ToString,“Test ”+system.DateTime.Now.ToString(“dd.MM.yy HH;mm;ss”)+".csv")

4 Likes

Perfect! :slight_smile: