private string createHtmlDoc(Codewatcher_V1_Lib.TreeNode currentNode, string HtmlDoc) { try { string innerHtml = ""; string[] splittedPath = currentNode.value.Split('.'); int length = splittedPath.Length; HtmlDoc += "<li><ul>" + currentNode.value; if (splittedPath[splittedPath.Length - 1] == "cs") { string code = File.ReadAllText(currentNode.value); HtmlDoc += "<li><pre><code>" + code + "</code></pre></li>"; } foreach (Codewatcher_V1_Lib.TreeNode tn in currentNode.ChildNodes) { innerHtml = createHtmlDoc(tn, innerHtml); } HtmlDoc += innerHtml + "</ul></li>"; return(HtmlDoc); } catch (Exception ex) { ExceptionList.Add(ex.Message); return(null); } }
private void btn_GenerateHtmlFile_Click(object sender, RoutedEventArgs e) { try { listBox.Items.Clear(); if (FolderPath != null && targetFilename != null) { Codewatcher_V1_Lib.TreeNode root = DirectoryExplorer.GetFolderStructure(FolderPath); addListboxItems(root); string htmldoc = createHtmlDoc(root, ""); SaveTreeInHtmlFile(htmldoc); tblogs.Text = "Successfully generated!"; } else { tblogs.Text = "Enter a filename or enter a targetfile!!!"; } foreach (string s in ExceptionList) { tblogs.Text += s; } } catch (Exception ex) { ExceptionList.Add(ex.Message); } }
private void addListboxItems(Codewatcher_V1_Lib.TreeNode currendNode) { try { string[] splittedValue = currendNode.value.Split('.'); if (splittedValue[splittedValue.Length - 1] == "cs") { listBox.Items.Add(currendNode.value); } foreach (Codewatcher_V1_Lib.TreeNode tn in currendNode.ChildNodes) { addListboxItems(tn); } } catch (Exception ex) { tblogs.Text = ex.ToString(); } }