Skip to content

Instantly share code, notes, and snippets.

View ElliotWood's full-sized avatar

Elliot Wood ElliotWood

  • Lab3
  • Australia
  • 19:44 (UTC +10:00)
View GitHub Profile
@ElliotWood
ElliotWood / gist:5259940
Created March 28, 2013 02:10
Async in winforms kinda sux Here is a way better way to do it
//static for extension..
//this allows us to always make sure we're using our controls on the
//thread they were created on, regardless of the thread we're calling from...
public static class ISynchronizeInvokeExtensions
{
public static void InvokeEx<T>(this T @this, Action<T> action) where T : ISynchronizeInvoke
{
if (@this.InvokeRequired)
@this.BeginInvoke(action, new object[] { @this });
else
@ElliotWood
ElliotWood / gist:5259918
Last active December 15, 2015 12:28
Upload a File with FTP with C# example
private static void Upload(string ftpServer, string userName, string password, string filename)
{
using (System.Net.WebClient client = new System.Net.WebClient())
{
client.Credentials = new System.Net.NetworkCredential(userName, password);
client.UploadFile(ftpServer + "/" + new FileInfo(filename).Name, "STOR", filename);
}
}