Esempio n. 1
0
        //keep deleting files till it reaches the defined size
        public static bool DeleteFtpFiles(long size)
        {
            try
            {
                while (size > 32000000000)
                {
                    foreach (var fd in Sfdetail.Take(250))
                    {
                        FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://server/path/folder/" + fd.Key);

                        //network credentials
                        request.Credentials = new NetworkCredential("username", "password");

                        request.Method = WebRequestMethods.Ftp.DeleteFile;
                        FtpWebResponse response = (FtpWebResponse)request.GetResponse();
                        response.Close();
                    }

                    size = Ftpconn.TestMeth();
                }

                return(true);
            }
            catch (Exception dexp)
            {
                throw new Exception("Failed to delete file: " + dexp);
            }
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            long ts = Ftpconn.TestMeth();

            bool check = true;

            if (ts > 32000000000)
            {
                check = Ftpconn.DeleteFtpFiles(ts);
            }
        }