Archive for Settembre 3rd, 2007

Get Windows service executable path

Settembre 3rd, 2007

Description: Returns absolute path to the folder where the running service’s executable is located

Link: http://www.codekeep.net/snippets/eb2e15ed-e97c-4037-af70-8bbba71103c8.aspx

private string servicePath
{
	get
        {
		return Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetModules()[0].FullyQualifiedName);
	}
}

XML Document

Settembre 3rd, 2007

Description: Adding a xml declartaion to and creating a XMLDom

Link: http://www.codekeep.net/snippets/347d467a-45cc-4b0d-90ac-f3cc0ac69e6b.aspx

XmlDocument xDoc = new XmlDocument();

xDoc.LoadXml(xBookingResp.OuterXml.ToString());
XmlNode xNode =xDoc.CreateXmlDeclaration("1.0", "utf-8", null);
xDoc.InsertBefore(xNode, xDoc.DocumentElement);