2014-03-29 39 views

回答

1

您的解決方案將是3個步驟:從URL

1.下載文件
看一看System.Net.WebClient

using (WebClient Client = new WebClient()) 
{ 
    Client.DownloadFile("http://www.abc.com/file/song/a.mpeg", "a.mpeg"); 
} 


2.解壓文件
在.Net 4.5中,您可以查看System.IO.Compression.ZipFile

string startPath = @"c:\example\start"; 
string zipPath = @"c:\example\result.zip"; 
string extractPath = @"c:\example\extract"; 

ZipFile.CreateFromDirectory(startPath, zipPath); 
ZipFile.ExtractToDirectory(zipPath, extractPath); 


或者可能考慮SharpZipLib如果你想更強大的解決方案,以解壓縮

3.調度
你可以看看System.Timers;

public void MyMethod() 
    { 
     Timer timer = new Timer(); 
     timer.Interval = new TimeSpan(0, 15, 0).TotalMilliseconds; 
     timer.AutoReset = true; 
     timer.Elapsed += new ElapsedEventHandler(Timer_Elapsed); 
     timer.Enabled = true; 
    } 

    public void Timer_Elapsed(object sender, ElapsedEventArgs e) 
    { 
     //Do your stuff here 
    } 

合併這些併爲您的解決方案編碼。

+0

感謝Loki,感謝您的快速回復.... – ShubhVinay

+0

@ Loki- 您可以共享CreateFromDirectory(startPath,zipPath);和ExtractToDirectory(zipPath,extractPath);方法,你指導我做到這一點.. – ShubhVinay

+0

@ShubhVinay你需要添加參考'System.IO.Compression.FileSystem'。然後用'使用System.IO.Compression'包含庫,然後調用ZipFile.CreateFromDirectory或ZipFile.ExtractToDirectory – Loki