How to check if an FTP directory exists

Basically trapped the error that i receive when creating the directory like so. private bool CreateFTPDirectory(string directory) { try { //create the directory FtpWebRequest requestDir = (FtpWebRequest)FtpWebRequest.Create(new Uri(directory)); requestDir.Method = WebRequestMethods.Ftp.MakeDirectory; requestDir.Credentials = new NetworkCredential(“username”, “password”); requestDir.UsePassive = true; requestDir.UseBinary = true; requestDir.KeepAlive = false; FtpWebResponse response = (FtpWebResponse)requestDir.GetResponse(); Stream ftpStream = response.GetResponseStream(); ftpStream.Close(); response.Close(); … Read more

Monitor remote FTP directory

If polling the server is an option: from ftplib import FTP from time import sleep ftp = FTP(‘localhost’) ftp.login() def changemon(dir=”./”): ls_prev = set() while True: ls = set(ftp.nlst(dir)) add, rem = ls-ls_prev, ls_prev-ls if add or rem: yield add, rem ls_prev = ls sleep(5) for add, rem in changemon(): print(‘\n’.join(‘+ %s’ % i for … Read more

How to send arbitrary FTP commands in C#

I don’t think it can be done with FtpWebRequest… The only way to specify a FTP command is through the Method property, and the documentation states : Note that the strings defined in the WebRequestMethods.Ftp class are the only supported options for the Method property. Setting the Method property to any other value will result … Read more

System.Net.FtpWebRequest GetDateTimestamp example

Yep – thats pretty much what I ended up with. I went with something like this request = FtpWebRequest.Create(“ftp://ftp.whatever.com/somefile.txt”); request.Method = WebRequestMethods.Ftp.GetDateTimestamp; request.Proxy = null; using (FtpWebResponse resp = (FtpWebResponse)request.GetResponse()) { Console.WriteLine(resp.LastModified); }

Batch file to upload .txt to FTP

I just put HELLO.TXT in your ftp root by; 1. Saving this as MYFTP.bat: @echo off echo user [email protected]> ftpcmd.dat echo ahktest>> ftpcmd.dat echo put %1>> ftpcmd.dat echo quit>> ftpcmd.dat ftp -n -s:ftpcmd.dat ftp.proflightsimulatoreview.com del ftpcmd.dat 2. From the command line, in the same directory as MYFTP.BAT, running; MYFTP.BAT c:\temp\hello.txt result 220———- Welcome to Pure-FTPd … Read more

Can’t connect to FTP: (553) File name not allowed

Although replying to an old post just thought it might help someone. When you create your ftp url make sure you are not including the default directory for that login. for example this was the path which I was specifying and i was getting the exception 553 FileName not allowed exception ftp://myftpip/gold/central_p2/inbound/article_list/jobs/abc.txt The login which … Read more