Zip file & Folder Asp.Net ,C#

 Zip in Asp.Net, C#

string sPath = Server.MapPath("~") + "DownloadFolder";

string sPath = Server.MapPath("~") + "DownloadFolder";

string zipFullPath = Server.MapPath("~") + "DocumentFolder.zip";

ZipOutputStream zipOut = new ZipOutputStream(File.Create(zipFullPath));

foreach (string fName in Directory.GetFiles(sPath))

{

FileInfo fi =
new FileInfo(fName);

ZipEntry entry = new ZipEntry(fi.Name);

FileStream sReader = File.OpenRead(fName);byte[] buff = new byte[Convert.ToInt32(sReader.Length)];

sReader.Read(buff, 0, (int)sReader.Length);

entry.DateTime = fi.LastWriteTime;

entry.Size = sReader.Length;

sReader.Close();

zipOut.PutNextEntry(entry);

zipOut.Write(buff, 0, buff.Length);

}

zipOut.Finish();

zipOut.Close();

Dont forget to import the fully qualified namespace using ICSharpCode.SharpZipLib.Zip ;)

By: VidyaGyan

check internet Connection c#

check internet connection availiblty in c# .net

Method 1.

bool ConnectionExists()
{

try

{

System.Net.
IPHostEntry objIPHE = System.Net.Dns.GetHostEntry("www.google.com");

return true;
}

catch

{

return false;

}

}

Method 2.

bool ConnectionExists()
{

try

{

System.Net.Sockets.
TcpClient clnt = new System.Net.Sockets.TcpClient("www.google.com", 80);

clnt.Close();

return true;

}

catch (System.Exception ex)

{

return false;

}

}

Blog by: VidyaGyan

live cricket score on your website

live cricket score on your website

place this html code on your page to see live cricket score

<object align="middle" width="300px" height="273px" id="InsertWidget_82704aaf-e824-40ea-9d26-8fa17d878113" type="application/x-shockwave-flash" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"><param value="http://www.widgetserver.com/syndication/flash/wrapper/InsertWidget.swf" name="movie"><param value="high" name="quality"><param value="transparent" name="wmode"><param value="false" name="menu"><param value="r=2&amp;appId=82704aaf-e824-40ea-9d26-8fa17d878113" name="flashvars"><param value="sameDomain" name="allowScriptAccess"> <embed align="middle" width="300px" height="273px" flashvars="r=2&amp;appId=82704aaf-e824-40ea-9d26-8fa17d878113" allowscriptaccess="sameDomain" wmode="transparent" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" menu="false" quality="high" name="InsertWidget_82704aaf-e824-40ea-9d26-8fa17d878113" src="http://www.widgetserver.com/syndication/flash/wrapper/InsertWidget.swf">



</
object>






kill process web browser

kill process of  web browsers c#

using System.Diagnostics;

Process[] process_list = Process.GetProcesses();

foreach (Process process in process_list)

{

if (process.ProcessName.ToLower().Contains("firefox".ToLower()))

{

process.Kill();

}

else if (process.ProcessName.ToLower().Contains("chrome".ToLower()))

{

process.Kill();

}

else if (process.ProcessName.ToLower().Contains("iexplore".ToLower()))

{

process.Kill();

}

}

Auto Click

 

VidyaGyan


Auto Click Mouse C# Code

Auto Click, Auto Move,  Auto DoubleClick, Auto Right Click Mouse in C# .Net

//Create Class MouseWork
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Runtime.InteropServices;
using System.Collections;

class MouseWork
{
[
DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
public static extern void mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);
[DllImport("user32")]
public static extern int SetCursorPos(int x, int y);
public void Click()
{
mouse_event(0x0002, 0, 0, 0, 0);
/* left button down value=0x0002 */
mouse_event(0x0004, 0, 0, 0, 0);/* left button down value=0x0004 */

}
public void Double_Click()
{
mouse_event(0x0002, 0, 0, 0, 0);
/* left button down value=0x0002 */
mouse_event(0x0004, 0, 0, 0, 0);/* left button down value=0x0004 */
Thread.Sleep(100);
mouse_event(0x0002, 0, 0, 0, 0);/* left button down value=0x0002 */
mouse_event(0x0004, 0, 0, 0, 0);/* left button down value=0x0004 */
}public void Right_Click()
{
mouse_event(0x0008, 0, 0, 0, 0);
/* right button down value=0x0008 */
mouse_event(0x0010, 0, 0, 0, 0); /* right button up value=0x0010 */
}public void Move_Cursor(int x, int y)
{
SetCursorPos(x, y);
//move_Cursor
}

}
//Note:Add your NameSpace if needed


//Using MouseWork Class
MouseWork mouse = new MouseWork();






mouse.Move_Cursor(0,0);

mouse.Click();

------------------------------------------------------------------------------------------------------

By: Pankaj Sharma