Tuesday, August 20, 2013

Merge multi files into single file.

Code below will merge the multiple files into single file. This will work in C# 4.0 framework on wards. tempFiles is the string , holding the filepath+name of the files . Between each files a separator',' is present. 

            string[] split = tempFiles.Split(',');
            string export_file = "MergedFiles.txt";
            File.WriteAllLines(filePath + export_file, split.SelectMany(File.ReadLines));

Thursday, August 1, 2013

Logic to load the list with the series of excel columns (alphabetic).

Logic to load the list with the series of excel columns (alphabetic) by giving the number of columns is required.




Later this list can be useful for creating data column on DataTable.

for Example, if you want to create 30 columns , list will be filled with
A
B
C
D
E
.
.
.
AA
AB
AC
AD


      static void Alpha(ref List<string> col, List<string> alp,int num)
        {
            string temp = "";
            int set = 0;
            int j = 1;

            for(int i=0 ;i<num;i++)
            {              
                col.Add(temp + alp[j-1]);
             
                if (j % alp.Count == 0)
                {
                    temp = col[set];
                    set++;
                    j = 0;
                }
                j++;
             
            }
        }


       static void Main(string[] args)
        {
            List<string> alp = new List<string>() { "A","B","C","D","E","F","G","H","I","J","K","L",
                                                    "M","N","O","P","Q","R","S","T","U","V","W","X",
                                                    "Y","Z"};
            List<string> columns = new List<string>();
            int numOfCols = 30;
            Alpha(ref columns, alp, numOfCols);
         }




Code Formater

Paste Here Your Source Code
Source Code Formatting Options
1) Convert Tab into Space :
2) Need Line Code Numbering :
3) Remove blank lines :
4) Embeded styles / Stylesheet :
5) Code Block Width :
6) Code Block Height :
7) Alternative Background :
Copy Formatted Source Code
 
Preview Of Formatted Code