Geeks With Blogs
Rohit Gupta Engaging talk on Microsoft Technologies ....My Resume
April 2009 Entries
Convert IP to Long and Vice Versa C#
The inbuilt function in System.Net.IPAddress(IPAddr... method returns IP’s in the reverse order, hence I had to look for alternatives. Here is the correct version to convert IP address to long and viceversa 1: static public string LongToIP(long longIP) 2: { 3: string ip = string.Empty; 4: for (int i = 0; i < 4; i++) 5: { 6: int num = (int)(longIP / Math.Pow(256, (3 - i))); 7: longIP = longIP - (long)(num * Math.Pow(256, (3 - i))); 8: if (i == 0) 9: ip = num.ToString(); 10: else 11: ip ......

Posted On Wednesday, April 29, 2009 11:16 AM

Using GZipStream to zip all files in folder
There is a neat little trick that one has to follow inorder to zip a entire folder into a gzip file. It is essentially a two step process Zip individual files in a folder using TarArchive Zip the tar file using GZip 1: public static string CreateTar(string directoryToCompress, string destPath, string tarFile) 2: { 3: string destDrive = destPath.Substring(0, destPath.IndexOf(@"\") + 1); 4: Directory.SetCurrentDirecto... 5: string tarFilePath = Path.Combine(destPath, tarFile); 6: using (Stream ......

Posted On Thursday, April 9, 2009 9:47 PM

Copyright © Rohit Gupta | Powered by: GeeksWithBlogs.net