Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
4.2k views
in .NET FTP by (200 points)
I am using a free version of the library and MSVS2003 with C#. I am trying to right a small test program to upload a txt file from local dir to the doc server. Here is most of the code:

private void Button1_Click(object sender, System.EventArgs e)
{
string step = "";
FTPClient ftp = null;
try
{
step = "1";

ftp = new FTPClient();
ftp.RemoteHost = "xx.x.xx.xxx";

step += "2";

ftp.Connect();

step += "3";

ftp.Login("user???????", "pass???????");

step += "4";

ftp.ConnectMode = FTPConnectMode.PASV;
ftp.TransferType = FTPTransferType.ASCII;

step += "5";

ftp.ChDir("PA");

step += "6";

if (ftp.IsConnected)
{
step += "7";

ftp.Put("C:/A-Temp/test.txt", "test.txt");
}

step += "8";

ftp.Quit();

step += "9";

}
catch ()
{
//----------------- Desplay message box ----------------
string strJScript11 = "<script type='text/javascript'>alert('" + step + "')</script>";
this.Controls.Add(new LiteralControl(strJScript11));
//======================== Fin =========================
}

}


I am able to MkDir so the connection is there.
This code stops at step 7 meaning the "ftp.Put("C:/A-Temp/test.txt", "test.txt"); generate an error.

Can someone help me with this. Thanks.

5 Answers

0 votes
by (162k points)
Generate a log file and post it here. That'll show the problem very quickly. Search the forums or look at the documentation for enabling logging.
0 votes
by (200 points)
OK. The Put and Get works fine. The only problem is that in

ftp.Put("C:\\A-Temp\\test.txt", "test.txt");

the C:\\A-Temp\\ is the hosting server path NOT my local C:\\A-Temp\\ directory.

Can someone tell me how to access files on my local drive and pass it to ftp.Put(...); ?

Thanks.
0 votes
by (162k points)
Oh, is this in ASP.NET? ASP's run on the ASP.NET server, not the client. You can't FTP from the client that way.
0 votes
by (200 points)
So, please tell me what can I do?
0 votes
by (162k points)
Well, you can't use ASP.NET to FTP files to and from the machine that is running the web browser.

You can use 1) HTTP upload or 2) consider a Java applet (see http://www.enterprisedt.com/products/in ... rview.html) or some other mechanism (perhaps WPF or Silverlight?)

Categories

...