-
April 4th, 2011, 01:42 AM
#1
How to download Ftp files by date
Hi,
Hi,
my Question is
1) i can download ftp files through my server.
2) but can any one say me how to download ftp files by date
EX: xys03-01-2011.zip
xys03-31-2011.zip
the code which i use is
static void Main(string[] args)
{
string dateString = DateTime.Now.ToString("MM-dd-yyyy");
string filename = string.Format("xys{0}.zip", dateString);
string localPath = "c:\\";
string fileName = filename;
string defaultLocalFolder_MCX = "C:\\";
FastZip fzMCX = new FastZip();
try
{
fzMCX.ExtractZip(defaultLocalFolder_MCX + "\\" + "xys03-31-2011.zip", defaultLocalFolder_MCX, "");
}
catch (Exception)
{
}
FtpWebRequest requestFileDownload = (FtpWebRequest)WebRequest.Create("ftp://localhost/Source/" + fileName);
requestFileDownload.Credentials = new NetworkCredential("test", "test");
requestFileDownload.Method = WebRequestMethods.Ftp.DownloadFile;
FtpWebResponse responseFileDownload = (FtpWebResponse)requestFileDownload.GetResponse();
Stream responseStream = responseFileDownload.GetResponseStream();
FileStream writeStream = new FileStream(localPath + fileName, FileMode.Create);
int Length = 2048;
Byte[] buffer = new Byte[Length];
int bytesRead = responseStream.Read(buffer, 0, Length);
while (bytesRead > 0)
{
writeStream.Write(buffer, 0, bytesRead);
bytesRead = responseStream.Read(buffer, 0, Length);
}
responseStream.Close();
writeStream.Close();
requestFileDownload = null;
responseFileDownload = null;
}
please help me
Thanks in Advance
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|