Unique report export name?
Hi Everyone,
I have an issue with a workflow exporting files to CSV (or excel), and giving it a unique name each time.
What's going on : Currently whenever the workflow exports the data as a csv file it gives the file the name "Report_CompanyName.xls". It takes the Company's Name that was entered into the beginning display form and puts it into the exported file name. HOWEVER, the issue i've noticed is that c ompanies will run the tool more than once, which then causes the CSV file to be overwritten with the most recently run info because the company's name is the same.
Is there a way to export the CSV file with the name "Report.CompanyName_DateTime.xls" ? I'd like to put a DateTime stamp at the end, however whenever I tried I get the error "The given paths format is not supported." The syntax I usd to create the Path, using the WriteFile function, is "C:\Inetpub\wwwroot\HED_Data\Report_" + company + DateTime.Now().ToString() + ".xls"
Any ideas or help would be greately appreciated.
Thank You,
Laura
-
Hi Laura,
Both the forward slash (/) and the colon (:) are invalid characters in a Widows file name. The replace fuction can be added to your string so that these characters are changed to something acceptable to Windows.
Try:
"C:\Inetpub\wwwroot\HED_Data\Report_" +company +DateTime.Now().ToString().replace("/","-").replace(":","_") + ".xls"
This change will put dashes for forward slashes, and underscores for colons; you can change thse to other characters as long as they are valid for a filename.
See http://msdn.microsoft.com/en-us/library/fk49wtc1(v=vs.110).aspx
regards,
Edmond
0 -
Or add something like this to the filename:
DateTime.Now.ToString("_yyyyMMdd_HHmmss")
0 -
Thanks everyone, It's now working perfect!
0
Please sign in to leave a comment.
Comments
3 comments