Copying file from one destination to another destination in C# using System.IO.File Class

Step 1: Import System.IO class
Step 2: Create a test file in your local system.
Step 3: Give Source and Destination Path, which should be available on your system.
Step 4: Combine Path with File name using System.IO.Path class. You can also using basic string concordinate.
Step 5: Check if Direct is exist before moving the file.
Step 6: Use File.Copy static method to move the file.

Note: If you have any queries, please write in below comment box.

C# Program to find Happy and Sad Number


As per Wiki, 

Happy Number – A happy number is a number defined by the following process: Starting with any positive integer, replace thenumber by the sum of the squares of its digits, and repeat the process until the number either equals 1 (where it will stay), or it loops endlessly in a cycle that does not include 1, 7, 10, 13, 19, 23, 28, 31, 32, 44, 49, 68, 70, 79, 82, 86, 91, 94, 97, 100..

Sad Number – An unhappy number is a number that is not happy, i.e., a number such that iterating this sum-of-squared-digits map starting with never reaches the number 1. The first few unhappy numbers are 2, 3, 4, 5, 6, 8, 9, 11, 12, 14, 15, 16, 17, 18…



Case 1

Enter the number:

Case 2

Enter the number: