Exemplo n.º 1
0
        public static void ExportCSVFile(string FolderPath, string ModuleName, string userFullName, Dictionary <string, string> Params, string SPName, string ReturnParam = null)
        {
            string FileName = ModuleName + "_" + userFullName + "_" + ApplyDateFormat(DateTime.Now) + ".csv";

            if (!Directory.Exists(FolderPath))
            {
                try
                {
                    Directory.CreateDirectory(FolderPath);
                }
                catch (Exception ex)
                {
                    FolderPath = null;
                }
            }

            if (File.Exists(FolderPath + FileName))
            {
                File.Delete(FolderPath + FileName);
            }
            if (FolderPath != null)
            {
                if (ReturnParam == null)
                {
                    Queries.CSVFileDownloadFromSP(SPName, ref Params, ",", FolderPath + FileName);
                }
                else
                {
                    Queries.CSVFileDownloadFromSP(SPName, ref Params, ",", FolderPath + FileName, ReturnParam);
                }

                DownloadFileFromServer(FolderPath, FileName);
            }
        }