Exemplo n.º 1
0
        public void DeleteFile1()
        {
            ServerDeleteFile sp = new ServerDeleteFile();

            sp.Start();
            string uri = String.Format("ftp://{0}:{1}/file.txt", sp.IPAddress, sp.Port);

            try {
                FtpWebRequest ftp = (FtpWebRequest)WebRequest.Create(uri);
                Console.WriteLine(ftp.RequestUri);
                ftp.KeepAlive = false;
                ftp.Timeout   = 5000;
                ftp.Method    = WebRequestMethods.Ftp.DeleteFile;
                ftp.UseBinary = true;
                FtpWebResponse response = (FtpWebResponse)ftp.GetResponse();
                Assert.IsTrue((int)response.StatusCode >= 200 && (int)response.StatusCode < 300, "DF#01");
                response.Close();
            } catch (Exception e) {
                Console.WriteLine(e);
                if (!String.IsNullOrEmpty(sp.Where))
                {
                    throw new Exception(sp.Where);
                }
                throw;
            } finally {
                sp.Stop();
            }
        }
		public void DeleteFile1 ()
		{
			ServerDeleteFile sp = new ServerDeleteFile ();
			sp.Start ();
			string uri = String.Format ("ftp://{0}:{1}/file.txt", sp.IPAddress, sp.Port);
			try {
				FtpWebRequest ftp = (FtpWebRequest) WebRequest.Create (uri);
				Console.WriteLine (ftp.RequestUri);
				ftp.KeepAlive = false;
				ftp.Timeout = 5000;
				ftp.Method = WebRequestMethods.Ftp.DeleteFile;
				ftp.UseBinary = true;
				FtpWebResponse response = (FtpWebResponse) ftp.GetResponse ();
				Assert.IsTrue ((int) response.StatusCode >= 200 && (int) response.StatusCode < 300, "DF#01");
				response.Close ();
			} catch (Exception e) {
				Console.WriteLine (e);
				if (!String.IsNullOrEmpty (sp.Where))
					throw new Exception (sp.Where);
				throw;
			} finally {
				sp.Stop ();
			}
		}