Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i created a console application which will convert the IList into PDF, EXCEL, and HTML in a specific folder, the .exe will run every half an hour so, now just i want to create a folder with current time every time the exe runs before the file generation and then all files will in that particular run time folder.

EX. 12/11/2017_10:30 --> FOLDER NAME RUNS AT 10.30
ex2. 12/11/2017_12:30 --> FOLDER NAME RUNS AT 12.30

inside the folder all three files should be there.

What I have tried:

 public void GenerateResults()
        {
            if (InputDataPresent)
            {
                var filegen = new FileGenerator(_data.Data, this.Filename, _cfg.AppSetupInfo.BaseFilePath);
                var filenamewithpath = string.Format("{0}\\{1}", _cfg.AppSetupInfo.BaseFilePath, this.Filename);

                foreach (var item in _cfg.ReportRunInfo.Formats)
                {
                    if (item.Format == ReportRunFormat.PDF)
                    {
                        if (filegen.ExportToPdf())
                        {
                            Result.Add(item.Format, string.Format("{0}.pdf", filenamewithpath));
                                                                
                        }
                    }
                    if (item.Format == ReportRunFormat.EXCEL)
                    {
                        if (filegen.ExportToExcel())
                        {
                            Result.Add(item.Format, string.Format("{0}.xlsx", filenamewithpath));
                        }
                    }
                    if (item.Format == ReportRunFormat.HTML)
                    {
                        if (filegen.ExportToHtml())
                        {
                            Result.Add(item.Format, string.Format("{0}.html", filenamewithpath));
                        }
                    }
                }
            }
string basepath =@"\\corp\dfsroot\global\Apps\GApps\GAppsdev\ProxyVoting\Reports\VDR";
        private string getfilename ()
        {
            //string date = DateTime.Now.ToString("yyyy-mm-dd-HH-MM-ss");
            string date = DateTime.Now.ToString("MM-dd-yyyy_HH-mm-ss");
            string fullname =_cfg.UserInfo.User.FullName;
            return string.Format("{0}_{1}", fullname, date);
        }
Posted
Updated 11-Dec-17 3:31am
Comments
BillWoodruff 11-Dec-17 10:27am    
Have you tried to create the folder name/path ? If so, show the code and describe any problems with it: if not, why not ?

1 solution

Using your principal, you can build any allowed filename:

private string getfilename ()
        {            
            string dateWithSeconds = DateTime.Now.ToString("MM-dd-yyyy_HH-mm-ss");
			string dateWithMinutes = DateTime.Now.ToString("MM-dd-yyyy_HH-mm");
            string fullname =_cfg.UserInfo.User.FullName;
            return string.Format("{0}_{1}\\{2}", fullname, dateWithMinutes, dateWithSeconds);
        }
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900