Archive

Archive for December, 2012

MVC Models in LINQtoSQL way

December 21, 2012 Leave a comment

ASPNET_MVC_Tutorial_10_CS

A sample tutorial i found while learning LINQ2SQL in MVC3 . Dont remember the resource owner or source site, But is really a useful post

Categories: Prsnl References Tags: ,

Async. Download progress bar c#

December 4, 2012 Leave a comment

The code for creating an async. download progress bar , allows user to track how much data is downloaded

WebClient client = new WebClient();

client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged);

client.DownloadFileCompleted += new AsyncCompletedEventHandler(client_DownloadFileCompleted);

//// Starts the download

string folder_path =”Location to save file”;

client.DownloadFileAsync(new Uri(downloadUrl), folder_path,””);

void client_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)

{

double bytesIn = double.Parse(e.BytesReceived.ToString());

double totalBytes = double.Parse(e.TotalBytesToReceive.ToString());

double percentage = bytesIn / totalBytes * 100;

 

downloadProgress.Text = int.Parse(Math.Truncate(percentage).ToString()).ToString()+” % finished”;

}

Categories: Prsnl References Tags: , , , ,