Wednesday, June 20, 2012

asp.net c# write to txt file


string path = HttpContext.Current.Server.MapPath("~/xxxxxxxx.txt");
                if (!System.IO.File.Exists(path))
                {
                    // Create a file to write to.
                    using (StreamWriter sw = System.IO.File.CreateText(path))
                    {
                        sw.WriteLine("-------------------------------------------------------------------------------------------------------------------------------------");
                        sw.WriteLine("-------------------------------------------------------------------------------------------------------------------------------------");
                        sw.WriteLine("------------------------Some explanation of the purpose of this file-----------------------------");
                        sw.WriteLine("-------------------------------------------------------------------------------------------------------------------------------------");
                        sw.WriteLine("-------------------------------------------------------------------------------------------------------------------------------------");
                    }
                }
                using (StreamWriter sw = System.IO.File.AppendText(path))
                {
                    StringBuilder sb = new StringBuilder();
                    sb.AppendLine("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -");
                    sb.AppendLine("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -");
                    sb.AppendLine("WHEN: " + DateTime.Now.ToString());
                    sb.AppendLine("WHO: " + GetCurrentUser());
                    IPHostEntry host;
                    host = Dns.GetHostEntry(Dns.GetHostName());
                    foreach (IPAddress ip in host.AddressList)
                    {
                        if (ip.AddressFamily.ToString() == "InterNetwork")
                        {
                            sb.AppendLine("WHERE: " + ip.ToString());
                            break;
                        }
                    }
                    sb.AppendLine("WHAT: " + errorMsg);
                    sb.AppendLine();
                    sb.AppendLine();
                    sb.AppendLine();
                    sw.WriteLine(sb.ToString());
                }


Tuesday, June 19, 2012

.NET Web Application install default SqlMembershipProvider schema

find and run the following executable inside "%Windows\Microsoft.NET\[framework number]\[version number]\"

aspnet_regsql.exe

Friday, June 15, 2012

RadGrid ItemCommand Find Control

if the control you are looking for is a button:
((Button)e.CommandSource)


if the control you are looking for is a label:
((Label)e.CommandSource)

Thursday, June 14, 2012

RadWindow Resize by Percentage


var width = $telerik.$(window).width() * 0.8;
                    var height = $telerik.$(window).height() * 0.95;
                    ExpWindow.setSize(width, height);
                    ExpWindow.center();

StimulSoft Report Web Designer Save Report

protected void StiWebDesigner1_SaveReport(object sender,

StiWebDesigner.StiSaveReportEventArgs e)
{
StiReport report = e.Report;
        string file = report.ReportFile;
        report.Save(file);
}