Posts

Showing posts from March, 2010

SFTPPro Example

first include the class in ur page using SFTPPro.SFTPServer; Example of SFTP Connection and methods Sftp sftpServer = new Sftp(strSFTPHost,strSFTPUserName,strSFTPPassword); sftpServer.Connect(); if (sftpServer.Connected) { ArrayList alFilelist=sftpServer.GetFileList(""); sftpServer.Get("strfromFilePath", "strToFilePath"); sftpServer.Put("strfromFilePath", "strToFilePath"); sftpServer.RemoveFile("<filename>"); } sftpServer.Close();

SFTPPro Example

first include the class in ur page using SFTPPro.SFTPServer; Example of FTP Connection and methods FTP FTPServer=new FTP("FtpHost", "username","password"); string []strResult=FTPServer.FileList(""); FTPServer.UploadFile("<DestinationFileName>", "<SourceFileName>"); FTPServer.DownloadFile("<SourceFileName>", "<DestinationFileName>"); FTPServer.RemoveFile("<FileName>"); FTPServer.MakeDirectory("<DirectoryName>"); FTPServer.RemoveDirectory("<DirectoryName>");

SFTPPro, FTPPro

The following url is for the dll package of SFTPPro and FTPPro http://code.google.com/p/sftppro/

Decompress .gz file in C# ASP.NET

//Following Code will help u to decompress using ICSharpCode.SharpZipLib.GZip; Stream s = new GZipInputStream(File.OpenRead(@"C:\Sample.txt.gz")); FileStream fs = File.Create(@"C:\Sample.txt"); int size = 2048; byte[] writeData = new byte[2048]; while (true) { size = s.Read(writeData, 0, size); if (size > 0) { fs.Write(writeData, 0, size); } else { break; } } s.Close(); fs.Close(); ///Following code will use to compress the file to.gz Stream s = new GZipOutputStream(File.Create(@"C:\Sample.txt.gz")); FileStream fs = File.OpenRead(@"C:\Sample.txt"); byte[] writeData = new byte[fs.Length]; fs.Read(writeData, 0, (int)fs.Length); s.Write(writeData, 0, writeData.Length); s.Close(); fs.Close(); //Download the dll from here http://www.icsharpcode.net/OpenSource/SharpZipLib/Default.aspx