Rohit Gupta

Engaging talk on Microsoft Technologies ....My Resume

  Home  |   Contact  |   Syndication    |   Login
  39 Posts | 0 Stories | 52 Comments | 0 Trackbacks

News



Twitter












Archives

Image Galleries

Personal

April 2009 Entries

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...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

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...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati