How would I create a log.
What I would like to do is have the program start up and show the real time and a message.
the code i have so far from searching.
DateTime.Now.ToString("hh:mm:ss tt");
How would I create a log.
What I would like to do is have the program start up and show the real time and a message.
the code i have so far from searching.
DateTime.Now.ToString("hh:mm:ss tt");
I would recommend to use the log4net framework, instead of writing your own custom logging solution. You can visit the log4net website, here: http://logging.apache.org/log4net/index.html
Follow the documentation to set it up, and check out the examples they have. With it, you can log to the console, to the debug window, to an XML file, and even to the Windows Event Log.
Your question seems a bit ambiguous. Did you mean creating a log file, as Tekmaven gave you a suggestion on how to do it, or do you simply want a message to be shown (like: Good morning John, it is 08:15 AM) at your program startup?
Yes you are correct, I finally got that code to work.
I get some errors with this code any suggestions?
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Diagnostics;
using System.Windows.Forms;
using System.Linq;
using System.Xml.Linq;
namespace XML_News
{
public partial class News
{
public string GetNews(string xmlUrl)
{
try
{
System.Text.StringBuilder NewsBuilder = new System.Text.StringBuilder();
XDocument NewsFeed = XDocument.Load(xmlUrl);
foreach (XElement Element in NewsFeed...<root>...<NewsFeed>...<news>)
{
NewsBuilder.Append(((char)(61623)).ToString() + " " + Element.Value + System.Environment.NewLine + System.Environment.NewLine);
}
return NewsBuilder.ToString();
}
catch (Exception ex)
{
return "Could not retrieve news, " + ex.Message;
}
}
How can I create a XML page?
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.