Categories

View the contents of a zip file using SharpCompress

View the contents of a zip file using SharpCompress. You can get this from http://sharpcompress.codeplex.com

Example

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using SharpCompress.Reader;
using SharpCompress.Common;

namespace ZipExample
{
class Program
{
static void Main(string[] args)
{
//change the path to a zip file on your PC
using (Stream stream = File.OpenRead(@”C:\Users\iain\Downloads\wexample.zip”))
{
var reader = ReaderFactory.Open(stream);
while (reader.MoveToNextEntry())
{
if (!reader.Entry.IsDirectory)
{
Console.WriteLine(reader.Entry.FilePath);
reader.WriteEntryToDirectory(@”C:\temp”, ExtractOptions.ExtractFullPath | ExtractOptions.Overwrite);
}
}
}
}
}
}

Write to the event log

This example will write an entry to the application event log

using System;
using System.Diagnostics;

namespace Test
{
class Program
{
static void Main(string[] args)
{
EventLog.WriteEntry(“Service example”, “Service example”, System.Diagnostics.EventLogEntryType.Information);
}
}
}

List all installed Windows services

using System;
using System.Collections.Generic;
using System.Text;
using System.ServiceProcess;

namespace Test
{
class Program
{
static void Main(string[] args)
{
ServiceController[] services = ServiceController.GetServices();
foreach (ServiceController service in services)
{
Console.WriteLine(“Installed: ” + service.ServiceName);
}
}
}
}

Load jQuery from Google CDN

function jquery_cdn() {
   if (!is_admin()) {
      wp_deregister_script('jquery');
      wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js', false, '1.8.3');
      wp_enqueue_script('jquery');
   }
}
add_action('init', 'jquery_cdn');

Print a page using jQuery


This shows how to print a page using jQuery

$('a.printPage').click(function(){

           window.print();
           return false;
}); 

<!-- HTML: Print Page -->
<div>
        <a  href="#">Print</a>
</div>

Sticky Footer in jQuery

<script src=”https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js”></script>
<script>
function positionFooter() { var mFoo = $(“footer”); if ((($(document.body).height() + mFoo.outerHeight()) < $(window).height() && mFoo.css(“position”) == “fixed”) || ($(document.body).height() < $(window).height() && mFoo.css(“position”) != “fixed”)) { mFoo.css({ position: “fixed”, bottom: “0px” }); } else { mFoo.css({ position: “static” }); } } $(document).ready(function () { positionFooter(); $(window).scroll(positionFooter); $(window).resize(positionFooter); $(window).load(positionFooter); });
</script>