C#

(550) File unavailable (e.g., file not found, no access).

If you are getting above error while using FtpWebRequest method to upload file to a FTP sever, please check your URL, The URL must be case sensitive. Otherwise you will get this error.

Posted On Thursday, October 18, 2012 2:43 AM | Comments (1)

The remote server returned an error: 227 Entering Passive Mode
Today while uploading file to FTP sever, the codes throw an error - "The remote server returned an error: 227 Entering Passive Mode", after research, I got some knowledge in FTP working principle. FTP may run in active or passive mode, which determines how the data connection is established. Active mode: command connection: client >1024 -> server 21 data connection: client >1024 <- server 20 passive mode: command connection: client > 1024 -> server 21 data connection: client > ......

Posted On Tuesday, October 16, 2012 1:55 PM | Comments (4)

Encryption and Decryption in the .NET Framework
What Is Symmetric Encryption? Symmetric encryption uses the same key for both encryption and decryption. Symmetric Algorithm in the .NET Framework What Is Asymmetric Encryption? Asymmetric cryptography uses separate keys for encryption and decryption Encrypted Text with public key can be decrypted only with the private key Asymmetric Algorithm in the .NET Framework Hash Algorithm Has Algorithm in the .NET Framework What is Digital Signature? Hash + Asymmetric Encryption = Digital Signature ......

Posted On Wednesday, May 23, 2012 2:37 PM | Comments (0)

How to Implement Single Sign-On between Websites
Introduction Single sign-on (SSO) is a way to control access to multiple related but independent systems, a user only needs to log in once and gains access to all other systems. a lot of commercial systems that provide Single sign-on solution and you can also choose some open source solutions like Opensso, CAS etc. both of them use centralized authentication and provide more robust authentication mechanism, but if each system has its own authentication mechanism, how do we provide a seamless transition ......

Posted On Monday, July 9, 2012 7:42 PM | Comments (3)

How to remove the last character from Stringbuilder
We usually use StringBuilder to append string in loops and make a string of each data separated by a delimiter. but you always end up with an extra delimiter at the end. This code sample shows how to remove the last delimiter from a StringBuilder. using System; using System.Collections.Generic; using System.Text; using System.Linq; class Program { static void Main() { var list =Enumerable.Range(0, 10).ToArray(); StringBuilder sb = new StringBuilder(); foreach(var item in list) { sb.Append(item).Append(","); ......

Posted On Sunday, April 8, 2012 12:12 PM | Comments (2)

The device is not ready
When you retrieve the drive info using the DriveInfo class, if you don't use the IsReady property to test whether a drive is ready, it will throw error as "The device is not ready". so you must use IsReady property to determines if the drive is ready to be queried, written to, or read from. The following code example demonstrates querying information for all drives on current system. using System; using System.IO; class Test { public static void Main() { DriveInfo[] allDrives = DriveInfo.GetDrives(); ......

Posted On Sunday, March 18, 2012 6:16 PM | Comments (0)