FTP Tool Error

I am very new to .NET and I'm trying to create an FTP tool. I found the following code on the Microsoft site and created a class using it. When I try to execute it, I'm getting the following error:

"The requested URI is invalid for this FTP command"

I am running this as a web app on my local machine and trying to FTP a file to a Linux server. Any idea what I might be doing wrong. Any help would be greatly appreciated.

Here is my class:

using System;
using System.IO;
using System.Net;
using System.Text;

public class ftp
{
public ftp ()
{
// Get the object used to communicate with the server.
FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://69.94.78.121");
request.Method = WebRequestMethods.Ftp.UploadFile;

// This example assumes the FTP site uses anonymous logon.
request.Credentials = new NetworkCredential("username", "password");

// Copy the contents of the file to the request stream.
StreamReader sourceStream = new StreamReader("C:/Inetpub/wwwroot/cloakmanager/files2trans/ideas.txt");
byte[] fileContents = Encoding.UTF8.GetBytes(sourceStream.ReadToEnd());
sourceStream.Close();
request.ContentLength = fileContents.Length;

Stream requestStream = request.GetRequestStream();
requestStream.Write(fileContents, 0, fileContents.Length);
requestStream.Close();

FtpWebResponse response = (FtpWebResponse)request.GetResponse();

Console.WriteLine("Upload File Complete, status {0}", response.StatusDescription);

response.Close();
}
}

[5443 byte] By [Blacata] at [2007-12-20]
# 1

The problem might be that you are trying to copy a file without specifying a name for the destination.

Try:

FtpWebRequest request = (FtpWebRequest) WebRequest.Create ("ftp://69.94.78.121/destfile.txt");

change the file name as you prefer.

Regards
--mc

MarioCossi at 2007-9-9 > top of Msdn Tech,Visual C#,Visual C# General...
# 2
Awesome. Thanks. It worked. I was banging my head against the wall. I really appreciate it.
Blacata at 2007-9-9 > top of Msdn Tech,Visual C#,Visual C# General...