private void AcceptUploadedFile(string relCodeName) { if (FURBugList.HasFile) { if (Path.GetExtension(FURBugList.FileName).ToLower().Equals(".csv")) { if (FURBugList.FileBytes.LongLength < (25 * 1024 * 1024)) { var dirPath = Path.Combine(AppGlobal.AppDataDirectory, DDLExistingProducts.SelectedValue, DDLExistingVersions.SelectedValue, relCodeName); AppGlobal.CreateDirectory(dirPath); var csvFilePath = Path.Combine(dirPath, "BugList.csv"); FURBugList.SaveAs(csvFilePath); var cachedHTMLSnippetFilePath = Path.Combine(dirPath, "BugList.htmlSnippet"); if (File.Exists(cachedHTMLSnippetFilePath)) { File.Delete(cachedHTMLSnippetFilePath); } } else { throw new Exception(string.Format("Uploaded file {0}'s size 0x{1} exceeds the limit of 25MB.", FURBugList.FileName, FURBugList.FileBytes.LongLength.ToString("X16"))); } } else { throw new Exception(string.Format("Uploaded file {0} is not a CSV file.", FURBugList.FileName)); } } }
public bool SaveToFile(string productCodeName) { var dirPath = Path.Combine(AppGlobal.AppDataDirectory, productCodeName); var XMLFilePath = Path.Combine(dirPath, string.Format("{0}.{1}", CodeName, VerXMLExtension)); var xDoc = new XmlDocument(); var declarationNode = xDoc.CreateXmlDeclaration("1.0", "", ""); xDoc.AppendChild(declarationNode); var comment = xDoc.CreateComment(string.Format("This file contains information about {0} - {1}", CodeName, DisplayName)); xDoc.AppendChild(comment); var docRoot = xDoc.CreateElement(xtVersion); XmlNode ndCodeName = xDoc.CreateElement(xtVersionCode), ndDisplayName = xDoc.CreateElement(xtDisplayName), ndDescription = xDoc.CreateElement(xtDescription); ndCodeName.InnerText = CodeName; ndDisplayName.InnerText = DisplayName; ndDescription.InnerText = Description; docRoot.AppendChild(ndCodeName); docRoot.AppendChild(ndDisplayName); docRoot.AppendChild(ndDescription); xDoc.AppendChild(docRoot); try { AppGlobal.CreateDirectory(dirPath); xDoc.Save(XMLFilePath); return(true); } catch (Exception e) { throw new Exception(string.Format("Unable to save Version {0} to file.{1}Message:{2}.", CodeName, Environment.NewLine, e.Message), e); } }