public static string Compress(string s)
       {
           var bytes = Encoding.Unicode.GetBytes(s);
           using (var msi = new MemoryStream(bytes))
           using (var mso = new MemoryStream())
           {
               using (var gs = new GZipStream(mso, CompressionMode.Compress))
               {
                   msi.CopyTo(gs);
               }
               return Convert.ToBase64String(mso.ToArray());
           }
       }
       public static string Decompress(string s)
       {
           var bytes = Convert.FromBase64String(s);
           using (var msi = new MemoryStream(bytes))
           using (var mso = new MemoryStream())
           {
               using (var gs = new GZipStream(msi, CompressionMode.Decompress))
               {
                   gs.CopyTo(mso);
               }
               return Encoding.Unicode.GetString(mso.ToArray());
           }
       }
-------------------------------------------------------
 Other ways:-
       public static byte[] Compress(string s)
       {
           var bytes = Encoding.Unicode.GetBytes(s);
           using (var msi = new MemoryStream(bytes))
           using (var mso = new MemoryStream())
           {
               using (var gs = new GZipStream(mso, CompressionMode.Compress))
               {
                   msi.CopyTo(gs);
               }
               return mso.ToArray();
           }
       }
       public static string Decompress(byte[] s)
       {
           var bytes = (s);
           using (var msi = new MemoryStream(bytes))
           using (var mso = new MemoryStream())
           {
               using (var gs = new GZipStream(msi, CompressionMode.Decompress))
               {
                   gs.CopyTo(mso);
               }
               return Encoding.Unicode.GetString(mso.ToArray());
           }
       }

List ls = new List();
foreach (string line in assignment_lines)
{
    ls.AddRange(line.Split('='));
}
string[] strArray = ls.ToArray();
               var appPath = System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath + "xml";
                XmlDocument xmlDoc = new XmlDocument();
                XDocument xDoc = new XDocument();
                string bodyFile = Path.Combine(appPath, @"Destinations.xml");
                //xmlDoc.Load(bodyFile);
                xDoc = XDocument.Parse(bodyFile);

 public static string RemoveNamespace(XmlDocument xdoc)
        {
            // Regex to search for either xmlns:nsN="..." or xmlns="..."
            const string pattern = @"xmlns:?(\w+)?=""[\w:/.]+""";
            string xml = xdoc.OuterXml;

            Regex replace = new Regex(pattern);
            // Replace all occurances of the namespace declaration
            string temp = replace.Replace(xml, String.Empty);
            foreach (Match match in replace.Matches(xml))
            {
                // Loop through each Match in the Regex, this gives us the namespace aliases found
                if (match.Success && match.Groups.Count > 1)
                {
                    if (!String.IsNullOrEmpty(match.Groups[1].Value))
                    {
                        Regex alias = new Regex(@"\b" + match.Groups[1].Value + ":");
                        // Replace all occurances of the
                        temp = alias.Replace(temp, String.Empty);
                    }
                }
            }
            return temp;
        }

 public string AutoGenerateString(int lenght)
        {
            string def = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";//0123456789";
            Random rnd = new Random();
            StringBuilder ret = new StringBuilder();
            for (int i = 0; i < lenght; i++)
            {
                ret.Append(def.Substring(rnd.Next(def.Length), 1));
            }
            return ret.ToString();
        }




 
  jQuery UI Dialog - Modal message

 

 

 


 




 
   
    Your Message successfully display in popup.
 


 


Next PostNewer Posts Previous PostOlder Posts Home