I have thousands of files located in FTP server. My task is to download the files from ftpserver, then unzip the file, then process the file. For downloading i am using Tamir
library and for unzipping i am using Ionic.zip
and then processing the files.
When i used threads, downloading files from FTP server stopped, don't know the reason, Maybe FTP server is not allowing to download file by using threads. Then i used thread only for unzipping the file and for processing. This also failed with an error like
The process cannot access the file 'file ' because it is being used by another process`.
So now i am doing everything sequentially. Prototype of code is as shown below
static void Main(string[] args)
{
string FTPpah = "d://Testpath";
DonloadUnzipProcessFile(FTPpah);
}
private static void DonloadUnzipProcessFile(string FTPpah)
{
string Localpath = @"e://testpath";
//Using Tamir libraryr
DownloadFile(FTPpah,Localpath);
//Ionic.zip library
UnzipFile(Localpath);
//c#code
ProcessFile(Localpath);
}
Is there any way i can improve this task by using Threads
or Process
?
EDIT
downloading from FTP server can not be done by threads? If so i am thinking of unzipping and processing by using task. So i will create 10 task (TPL) each will take 10 files at a time and unzip, then ten task will process, are such scenarios possible?