Discuss (FTP), (FTP on .NET CF) and (FTPS, SFTP and SCP).

Put/Get problem

no avatar
User

Cez

Posts

3

Joined

Thu Jun 11, 2009 5:02 am

Put/Get problem

by Cez » Thu Jun 11, 2009 6:14 am

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.
no avatar
User

support2

Posts

3987

Joined

Tue May 18, 2004 8:30 am

Re: Put/Get problem

by support2 » Thu Jun 11, 2009 1:20 pm

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.
no avatar
User

Cez

Posts

3

Joined

Thu Jun 11, 2009 5:02 am

by Cez » Fri Jun 12, 2009 3:03 am

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.
no avatar
User

support2

Posts

3987

Joined

Tue May 18, 2004 8:30 am

by support2 » Fri Jun 12, 2009 5:44 am

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.
no avatar
User

Cez

Posts

3

Joined

Thu Jun 11, 2009 5:02 am

by Cez » Fri Jun 12, 2009 5:58 am

So, please tell me what can I do?
no avatar
User

support2

Posts

3987

Joined

Tue May 18, 2004 8:30 am

by support2 » Fri Jun 12, 2009 6:16 am

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?)

Who is online

Users browsing this forum: No registered users and 10 guests

Powered by phpBB ® | phpBB3 Style by KomiDesign