Thursday, August 12, 2010

System.Windows.Xps.Packaging - Reach Framework => Add reference DLL

Hello Guys,

If you need to use XpsDocument class in your project, you must add reference to System.Windows.Xps.Packaging namespace. It is defined in the ReachFramework.

In order to add reference to ReachFramework, you right click on Add Reference on the project name in Solution Explorer. On the .NET Framework, select ReachFramework and other assemblies from the list and click OK button




Hope you find it useful.
Thanks,
Nitin Sharma
.


Tuesday, August 10, 2010

Database Back up using SQL Query

Hi All,
Today i came through a problem where in i have to take Back up of the SQL server database .
It is a simple query :

BACKUP DATABASE TestDB TO DISK='D:\MyDatabase.bak' with FORMAT


Where
"TESTDB" => Your Database Name
"D:\" => Any local Hard Drive C,D,E,F or any;
"MyDataBase" => Any name by which you want to take Back up.


Thanks,
Nitin Sharma

Ancient Saying - Pehla Sukh Nirogi Kaya . . . .

Below is one of the ancient saying that i would like to share with you.It is well said by our ancestors & has a deeper meaning in terms of living life.Our life is complete then.

PEHLA SUKH NIROGI KAYA
DOOSRA SUKH GHAR MEIN HO MAYA
TEESRA SUKH KULWANTI NARI
CHAUTHA SUKH PUTRA AGYAKARI

You have bliss if you have a healthy body
You have bliss if you have a home filled with wealth
You have bliss if you have a faithful wife
You have bliss if you have an obedient son.


Thanks,
Have a Nice Day.!
Nitin Sharma

Monday, June 14, 2010

IM Chat with God : i like it much

Did You Call Me?
===========

God: Hello. Did you call me?
Me: Called you? No... Who is this?

God: This is GOD. I heard your prayers.
So, I thought I will chat.
Me: I do pray. Just makes me feel good.
I am actually busy now.

God: What are you busy at? Ants are busy too.
Me: Don't know. But, I can't find free time.
Life has become hectic. It's rush hour all the time.

God: Sure. Activity gets you busy.
Productivity gets you results.
Activity consumes time. Productivity frees it.
Me: I understand. Yet, I still can't figure out. By the way,
I was not expecting YOU to call me on instant messaging chat

God: I wanted to solve your fight for time, by giving you some
clarity. In this internet era, I wanted to reach you
through the way in which you would understand.

Me: Tell me, why has life become complicated now?
God: Stop analyzing life. Just live it. Analysis makes it
complicated.

Me: Why are we constantly unhappy?
God: Your today is the tomorrow that you worried about
yesterday. You are worrying because you are analyzing.
Worrying has become your habit. That's why you are not
happy.

Me: How can we not worry when there is so much uncertainty?
God: Uncertainty is inevitable. Worrying is optional.

Me: There is so much pain due to uncertainty.
God: Pain is inevitable - it will come. Suffering is optional,
you can choose.

Me: If suffering is optional, why do good people also suffer?
God: Diamonds cannot be polished without friction.
Gold cannot be purified without fire.
Good people go through trials, but, don't suffer.
With that experience, their life becomes better,
not bitter.

Me: You mean to say such experience is useful?
God: Yes. Experience is a hard teacher.
She gives the test first and the lessons afterwards.

Me: Still, why should we go through such tests?
Why can't we be free from problems?
God: Problems are purposeful roadblocks offering beneficial
lessons to develop strength.
Inner strength comes from struggle and endurance,
not when you are free from problems.

Me: Frankly, in the midst of so many problems,
we don't know where we are heading...
God: If you look outside, you will not know where you are going.
Look inside.
Looking outside, you dream.
Looking inside, you awaken.
Eyes provide sight. Heart provides insight.

Me: Sometimes not succeeding fast seems to hurt more than
moving in the right direction. What should I do?
God: Success is a measurement decided by others.
Satisfaction is a measurement decided by you.
Knowing the road ahead is more satisfying.
You work with the compass. Let others work with the clock.

Me: In tough times, how do you stay motivated?
God: Always look at how far you have come rather than how far
you have to go.
Always count your blessing, not what you are missing.

Me: What surprises you about people?
God: When they suffer they ask, "Why me?"
When they prosper, they never ask "Why me?"
Everyone wishes to have truth on their side.
Few want to be on the side of the truth.

Me: Sometimes, I ask, "Who am I? Why am I here?"
I can't get the answer.
God: Seek not to find who you are, but, to determine who you
want to be. Stop looking for a purpose as to why you are
here. Create it.
Life is not a process of discovery.
It's a process of creation.

Me: How can I get the best out of life?
God: Face your past without regret.
Handle your present with confidence.
Prepare for the future without fear.

Me: One last question. Sometimes, I feel my prayers are not
answered.
God: There are no unanswered prayers. At times, the answer is
"NO."

Me: Thank you for this wonderful chat.
God: Well, keep the faith and drop the fear.
Life is a mystery to solve not a problem to resolve.

Trust me.


Friday, April 9, 2010

Fetch Files with more than one extension from a Directory and Sorth them

Hi All,
There may be requirements in your project sometimes where you may fetch files of Particular extensions from a directory.
The Simple way for extension say " .docx " , the Directory search pattern works.

string[] fns = Directory.GetFiles(@"D:\Documents\", "*.docx*");

However if you want to search files of more than one type(extension), here is the way.

CODE:

var sort = from fn in fns

where fn.Contains(".jpg") || fn.Contains(".txt") || fn.Contains(".png")

orderby new FileInfo(fn).CreationTime descending

select fn;


I hope you know var keyword :p.(The anonymous types introduced in C# 3.0).

In the above example it gives the collection.

So at the end you get filtered all files from the directory/folder by just providing the extension name in file.contains() syntax like fn.Contains(".jpg")

Also note that the files can also be sorted(ascending/descending) by file Size,lastAccess,LastWrite,CreationTime.
In above example the files are sorted by CreationTime.

Thanks,
Nitin Sharma
Happy Coding