Search Everything : Fast access tool on your drive

From: Saxena, Ritesh

Tool to access files,exe instantly using “Search Everything Tool” http://www.voidtools.com/faq.php

Here is the description of the tool:

"Everything" is an administrative tool that locates files and folders by filename instantly for Windows.

Unlike Windows search "Everything" initially displays every file and folder on your computer (hence the name "Everything").

You type in a search filter to limit what files and folders are displayed.

Advertisements

C# TimeZone Examples

http://www.dotnetperls.com/timezone

C# TimeZone Examples

You want to get information about the TimeZone that the current computer is in. Time zones on the planet Earth change on lines on longitude, and you cannot assume the current computer is in any particular time zone reliably. Fortunately, as we demonstrate in this example set, the TimeZone type provides information about time zones for C# programmers.

Time zone names

What is the name of a specific time zone? The .NET Framework contains information about the names for time zones; you can access the properties StandardName and DaylightName to get these strings. Also, this example as well as the following ones shows how you can get the current time zone with the TimeZone.CurrentTimeZone property accessor.

Program that gets time zone names [C#]
using System;
class Program
{
 static void Main()
 {
 // Get current time zone.
 TimeZone zone = TimeZone.CurrentTimeZone;
 string standard = zone.StandardName;
 string daylight = zone.DaylightName;
 Console.WriteLine(standard);
 Console.WriteLine(daylight);
 }
}
Output
 (This will depend on your computer's location and system settings.)
Mountain Standard Time
Mountain Daylight Time

Get universal time (local time)

There are two concepts of time you can use: the local time, which depends on where the computer is located on the Earth; and the universal time, which is independent of the computer’s location. If you use universal times, you can compare times from different locations with no errors.

Program that checks universal and local times [C#]
using System;
class Program
{
 static void Main()
 {
 TimeZone zone = TimeZone.CurrentTimeZone;
 // Demonstrate ToLocalTime and ToUniversalTime.
 DateTime local = zone.ToLocalTime(DateTime.Now);
 DateTime universal = zone.ToUniversalTime(DateTime.Now);
 Console.WriteLine(local);
 Console.WriteLine(universal);
 }
}
Output
 (This also depends on your computer's location.)
8/26/2010 1:02:28 PM
8/26/2010 7:02:28 PM

Get offsets

A UTC offset indicates how many hours a time zone differs from the Coordinated Universal Time (also referred to as Zulu Time or Greenwich Mean Time). When you call GetUtcOffset on a TimeZone instance, you get a TimeSpan instance that indicates how many hours the time is different from UTC.

TimeSpan Examples

Program that checks UTC offset [C#]
using System;
class Program
{
 static void Main()
 {
 TimeZone zone = TimeZone.CurrentTimeZone;
 // Get offset.
 TimeSpan offset = zone.GetUtcOffset(DateTime.Now);
 Console.WriteLine(offset);
 }
}
Output
 (Results vary on location.)
-06:00:00

Daylight changes

Daylight saving time was invented by George Vernon Hudson in New Zealand. Its intention is to save money by reducing the costs of keeping lights on at night. Today, its main purpose is to make software programmers’ lives hard. This short program shows how you can get information about the current year’s daylight saving changes: when the clock is set forward, and when this change is reverted.

Program that shows daylight changes [C#]
using System;
using System.Globalization;
class Program
{
 static void Main()
 {
 // Get daylight saving information for current time zone.
 TimeZone zone = TimeZone.CurrentTimeZone;
 DaylightTime time = zone.GetDaylightChanges(DateTime.Today.Year);
 Console.WriteLine("Start: {0}", time.Start);
 Console.WriteLine("End: {0}", time.End);
 Console.WriteLine("Delta: {0}", time.Delta);
 }
}
Output
 (Your mileage may vary.)
Start: 3/14/2010 2:00:00 AM
End: 11/7/2010 2:00:00 AM
Delta: 01:00:00

Daylight saving time

This program shows how you can scan individual dates for their daylight saving status. It is probably better to use the GetDaylightChanges method instead of the IsDaylightSavingTime method repeatedly; however, IsDaylightSavingTime can be useful in some cases.

Program that checks daylight saving time [C#]
using System;
class Program
{
 static void Main()
 {
 DateTime d = new DateTime(2010, 1, 1);
 TimeZone cur = TimeZone.CurrentTimeZone;
 bool flag = !cur.IsDaylightSavingTime(d);
 for (int i = 0; i < 365; i++)
 {
 bool f = cur.IsDaylightSavingTime(d);
 if (f != flag)
 {
 Console.WriteLine("{0}: begin {1}", d, f);
 flag = f;
 }
 d = d.AddDays(1);
 }
 }
}
Output
 (Depends on your time zone.)
1/1/2010 12:00:00 AM: begin False
3/15/2010 12:00:00 AM: begin True
11/8/2010 12:00:00 AM: begin False

Summary

The TimeZone type in the C# language and .NET Framework provides a handy way to get information about time zones. You can use the CurrentTimeZone property to get the information for the computer, and then call methods that reveal information about daylight saving time universal times and UTC offsets.

C#: Easy String to DateTime, DateTime to String and Formatting / CultureInfo.CurrentCulture / .NET: Convert DateTime from One TimeZone to Another

Easy String to DateTime, DateTime to String and Formatting

http://www.codeproject.com/KB/cs/String2DateTime.aspx

Introduction

In the few years that I have been a software developer, I have work with plenty of different programming languages. The first thing that causes you headaches in all of those languages are dates and how to work with them. In this little tutorial, I would like to show you how to work with dates in C# .NET 2.0.

String to DateTime

 // String to DateTime
 String MyString;
 MyString = "1999-09-01 21:34 PM";
 //MyString = "1999-09-01 21:34 p.m."; //Depends on your regional settings
 DateTime MyDateTime;
 MyDateTime = new DateTime();
 MyDateTime = DateTime.ParseExact(MyString, "yyyy-MM-dd HH:mm tt",
 null);

DateTime to String

 //DateTime to String
 MyDateTime = new DateTime(1999, 09, 01, 21, 34, 00);
 String MyString;
 MyString = MyDateTime.ToString("yyyy-MM-dd HH:mm tt");

Format String For Dates

Your format stringis your most important key. In most of my projects, I make it a constant and then refer to the constant value in my code.

The following is the most commonly used format characters:

d - Numeric day of the month without a leading zero.
dd - Numeric day of the month with a leading zero.
ddd - Abbreviated name of the day of the week.
dddd - Full name of the day of the week.
f,ff,fff,ffff,fffff,ffffff,fffffff - 
 Fraction of a second. The more Fs the higher the precision.
h - 12 Hour clock, no leading zero.
hh - 12 Hour clock with leading zero.
H - 24 Hour clock, no leading zero.
HH - 24 Hour clock with leading zero.
m - Minutes with no leading zero.
mm - Minutes with leading zero.
M - Numeric month with no leading zero.
MM - Numeric month with a leading zero.
MMM - Abbreviated name of month.
MMMM - Full month name.
s - Seconds with no leading zero.
ss - Seconds with leading zero.
t - AM/PM but only the first letter. 
tt - AM/PM ( a.m. / p.m.)
y - Year with out century and leading zero.
yy - Year with out century, with leading zero.
yyyy - Year with century.
zz - Time zone off set with +/-.

CultureInfo.CurrentCulture Property

http://msdn.microsoft.com/en-us/library/system.globalization.cultureinfo.currentculture.aspx

using System;

using System.Globalization;

using System.Security.Permissions;

using System.Threading;

[assembly:SecurityPermission( SecurityAction.RequestMinimum, ControlThread = true )]

public class SamplesCultureInfo {

public static void Main() {

// Displays the name of the CurrentCulture of the current thread.

Console.WriteLine( "CurrentCulture is {0}.", CultureInfo.CurrentCulture.Name );

// Changes the CurrentCulture of the current thread to th-TH.

Thread.CurrentThread.CurrentCulture = new CultureInfo( "th-TH", false );

Console.WriteLine( "CurrentCulture is now {0}.", CultureInfo.CurrentCulture.Name );

// Displays the name of the CurrentUICulture of the current thread.

Console.WriteLine( "CurrentUICulture is {0}.", CultureInfo.CurrentUICulture.Name );

// Changes the CurrentUICulture of the current thread to ja-JP.

Thread.CurrentThread.CurrentUICulture = new CultureInfo( "ja-JP", false );

Console.WriteLine( "CurrentUICulture is now {0}.", CultureInfo.CurrentUICulture.Name );

}

}

/*

This code produces the following output, if the ControlThread permission is granted (for example, if this code is run from the local drive).

CurrentCulture is en-US.

CurrentCulture is now th-TH.

CurrentUICulture is en-US.

CurrentUICulture is now ja-JP.

*/

.NET: Convert DateTime from One TimeZone to Another

http://www.xiirus.net/articles/article-_net-convert-datetime-from-one-timezone-to-another-7e44y.aspx

TimeZoneInfo timeZoneInfo;

DateTime dateTime ;

//Set the time zone information to US Mountain Standard Time

timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById("US Mountain Standard Time");

//Get date and time in US Mountain Standard Time

dateTime = TimeZoneInfo.ConvertTime(DateTime.Now, timeZoneInfo);

//Print out the date and time

Console.WriteLine(dateTime.ToString("yyyy-MM-dd HH-mm-ss"));