string _ftpURL = "testftp.com"; //Host URL or address of the FTP server string _UserName = "username"; //User Name of the FTP server string _Password = "Password"; //Password of the FTP server string _ftpDirectory = "FTP Foldername"; //The directory in FTP server where the files are present string _FileName = "niks.csv"; //File name, which one will be downloaded string _LocalDirectory = "D:\\"; //Local directory where the files will be downloaded DownloadFile(_ftpURL, _UserName, _Password, _ftpDirectory, _FileName, _LocalDirectory); public void DownloadFile(string ftpURL, string UserName, string Password, string ftpDirectory, string FileName, string LocalDirectory) { if (!File.Exists(LocalDirectory + "/" + FileName)) { try { FtpWebRequest requestFileDownload = (FtpWebRequest)WebRequest.Create(ftpURL + "/" + ftpDirectory + "/" + FileName); requestFileDownload.Credentials = new NetworkCredential(UserName, Password); requestFileDownload.Method = WebRequestMethods.Ftp.DownloadFile; FtpWebResponse responseFileDownload = (FtpWebResponse)requestFileDownload.GetResponse(); Stream responseStream = responseFileDownload.GetResponseStream(); FileStream writeStream = new FileStream(LocalDirectory + "/" + 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; } catch (Exception ex) { throw ex; } } }
Here, I will explain you how you can see logs of users. Step 1 : First, create a new database with name "test". Step 2 : Create a new table. Step 3 : Now, go and drop the table by running the following command. Step 4 : Now, select your database under Object Explorer and go to Reports >> Standard Reports >> Schema Changes History. Step 5 : You will then see the schema change history. The report will show you who has dropped this table. Finally, you can locate the user activity with the help of log.
Comments
Post a Comment