adorer

How can I find a source about ITC (Internet Transfer Control) with c#.net

because all the sources with VB and I want just one with c#

can any body help me (I am in a problem)....

thank you in advance



Re: Visual C# General Internet Transfer Control

MarcD

Hello Adorer. You do not really need to use the Internet Transfer Control anymore. It is a legacy control and if you are working with C# .NET then you have things such as WebClient (2.0) and httpWebRequest that can easily get/downloadweb pages, download files, and much more. Let us know what version of C#.NET you are using and what you are trying to do and somebody will be able to provide code. Thanks.



Re: Visual C# General Internet Transfer Control

adorer

I am using visual studio 2003 c#.net 2003

and it is a task in my workshop to learn and study about ITC (this is the first time I will use)

and they gave me some sources but in VB and I am not using VB at all >>>

so where can I find some sources in c#.net 2003

or at the least ... is it the same in visual studio ..

thank u very much again in advance





Re: Visual C# General Internet Transfer Control

adorer

The control must support both protocols HTTP and FTP



Re: Visual C# General Internet Transfer Control

MarcD

Weee

Well - that is extremely odd - since ITC should not really be used or need to be used. However - ITC is simply a COM Component. You need to add it to your Visual Studio Toolbox by right clicking and choose items -> wait a minute for a dialog to come up -> Choose COM COmponent tabs and either find it - or browse to the location.

If you have a form then you can simply drag it onto your form and you should be able to use it.

Below is some sample code that "worked" for me. It does have it's caveats.

#1 - you must drag the Inet control onto your form as i stated before. You must then attach the StateChanged event below to it. This is done visually by clicking on the inet control -> right clicking and going to prroperties. Click on the event tab (lightning symbol) and scroll down till you find StateChanged. Double click and then paste the code inside of this method into yours. if your control is not named axInet1 then please change it.

This also assumes you have a label, 2 text boxes

lblError

txtFTPSite

txtFileName

txtFTPSite for this demo had ftp://ftp.microsoft.com

IT MUST be a url, it cannot be simply a host. it will throw an exception.

filename can simply be a filename. Note that I hard coded the path to C:\ . Below it you will see some code i commented out that would put the file in the same directory as the application.

The major thing i should note is that the program seems to throw an exception if you have to specify a username/password - even if you set the username and password correctly. This could be due to the fact that I am using an older version of the control as microsoft does have a fix for the username/password. if you do need to set the username/password it is pretty simple. It is a property . I've commented a sample to show you. Hope this helps.

private void axInet1_StateChanged(object sender, AxInetCtlsObjects.DInetEvents_StateChangedEvent e)
{
switch ((InetCtlsObjects.StateConstants) e.state)
{
case InetCtlsObjects.StateConstants.icConnected: lblError.Text = "Connected"; break;
case InetCtlsObjects.StateConstants.icConnecting: lblError.Text = "Connecting"; break;
case InetCtlsObjects.StateConstants.icDisconnected: lblError.Text = "Disconnected"; break;
case InetCtlsObjects.StateConstants.icDisconnecting: lblError.Text = "Disconnecting"; break;
case InetCtlsObjects.StateConstants.icError: lblError.Text = "Error"; break;
case InetCtlsObjects.StateConstants.icHostResolved: lblError.Text = "Host Resolved"; break;
case InetCtlsObjects.StateConstants.icNone: lblError.Text = "None"; break;
case InetCtlsObjects.StateConstants.icReceivingResponse: lblError.Text = "Receiving Response"; break;
case InetCtlsObjects.StateConstants.icRequestSent: lblError.Text = "Request Sent"; break;
case InetCtlsObjects.StateConstants.icRequesting: lblError.Text = "Requesting"; break;
case InetCtlsObjects.StateConstants.icResolvingHost: lblError.Text = "Resolving Host"; break;
case InetCtlsObjects.StateConstants.icResponseCompleted: lblError.Text = "Response Completed"; break;
case InetCtlsObjects.StateConstants.icResponseReceived: lblError.Text = "Response Received"; break;
default:
break;
}
if (e.state==12)
{
lblError.Text = "File Transferred;";
}
lblError.Text += axInet1.ResponseCode + " : " + axInet1.ResponseInfo;
}

private void btnGetFile_Click(object sender, EventArgs e)
{
axInet1.Protocol = InetCtlsObjects.ProtocolConstants.icFTP;
axInet1.URL = txtFTPSite.Text;
Object Bleah = null;

//axInet1.UserName = "YouWishYouNewThePass";

//axInet1.Password = "YouWishYouNewThePass";

axInet1.Execute(txtFTPSite.Text, "GET " + txtFileName.Text + " " + @"C:\" + txtFileName.Text, String.Empty, String.Empty);
// Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), txtFileName.Text), String.Empty, String.Empty);
}





Re: Visual C# General Internet Transfer Control

adorer

thank you very much for your good answer ...

and hope it works