Sunday, 17 July 2011

C# DateTime Ticks Property

The DateTime Ticks property simply returns a long that represents the amount of ticks (100-nanosecond interval) that have passed since january 1, 0001 12:00:00.

using System;
class Program
{
    static void Main()
    {
        DateTime variable = DateTime.Now;
        long ticks = variable.Ticks;
        Console.WriteLine(ticks);
        Console.Read();
    }
}

output:633117518171562500


Convery Ticks Back to DateTime

Now that we have converted a DateTime object to a Ticks now we have to learn how to convert is back to a DateTime value.

using System;
class Program
{
    static void Main()
    {
        long ticks = 633117518171562500;
        DateTime date = new DateTime(ticks);
        Console.WriteLine(date.ToString());
        Console.Read();
    }
}


Output: 4/9/2007 9:43:37 PM


Thursday, 14 July 2011

Show a word document content in asp.net page

using Microsoft.Office.Interop.Word;
//fuction
  private void readFileContent(string path)

  {

       ApplicationClass wordApp = new ApplicationClass();

      object file = path;

      object nullobj = System.Reflection.Missing.Value;       

      Microsoft.Office.Interop.Word.Document doc = wordApp.Documents.Open(

      ref file, ref nullobj, ref nullobj,

      ref nullobj, ref nullobj, ref nullobj,

      ref nullobj, ref nullobj, ref nullobj,

      ref nullobj, ref nullobj, ref nullobj,

      ref nullobj, ref nullobj, ref nullobj, ref nullobj);

      doc.ActiveWindow.Selection.WholeStory();

      doc.ActiveWindow.Selection.Copy();

      string sFileText = doc.Content.Text;

      doc.Close(ref nullobj, ref nullobj, ref nullobj);

      wordApp.Quit(ref nullobj, ref nullobj, ref nullobj);       

      Response.Write(sFileText);

   }

Table Partitioning in SQL Server

  Table Partitioning in SQL Server – Step by Step Partitioning in SQL Server task is divided into four steps: Create a File Group Add Files ...