I am writing a program to copy files from a USB to an FTP server, and this is part of the code:
private const string ftp_url = @"ftp://an_ip_addrs/X";
private static void Upload(string sourceDir)
{
using (WebClient client = new WebClient())
{
try
{
client.Credentials = new NetworkCredential(ftp_username, ftp_psw);
foreach (var filename in Directory.GetFiles(sourceDir))
{
Console.WriteLine("Preparing to upload --> " + filename);
client.UploadFile(ftp_url, WebRequestMethods.Ftp.UploadFile, filename);
Console.WriteLine("File Uploaded!");
}
} catch (Exception e)
{
Console.WriteLine("Err FTP --> " + e);
}
}
}
This is the output from Preparing to upload
:
Preparing to upload --> C:\Users\aimproxy\jn54comu\FASM - Copy (10).PDF
Actually I get this err from the try catch block
:
"Err FTP --> System.Net.WebException: The remote server returned an error: (553) File name not allowed.
at System.Net.WebClient.UploadFile(Uri address, String method, String fileName)
at System.Net.WebClient.UploadFile(String address, String method, String fileName)
at usb_backdoor_csharp.Program.Upload(String sourceDir) in C:\Users\aimproxy\Desktop\Program.cs:line 29
As requested this is the Output from ftp.exe
Connected to 192.168.1.5.
220 Welcome to virtual FTP service.
503 USER expected.
User (192.168.1.5:(none)): upload
331 Password please.
230 User logged in.
ftp> dir
200 PORT 192.168.1.67:59392 OK
150 BINARY data connection established.
drwxrwxrwx 2 0 0 4096 Apr 22 18:07 X
226 Directory list has been submitted.
ftp: 135 bytes received in 0.02Seconds 7.50Kbytes/sec.