I don't know what you have their but it doesn't look like a ftp uploader to me? Here is an example of one that I have used before. It uses a form with a few text boxes and a couple of buttons. You dont have to use the form if you don't need it.
ex:
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.IO;
namespace FTPUploader
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void uploadFile(string FTPAddress, string filePath, string username, string password)
{
//Create FTP request
FtpWebRequest request = (FtpWebRequest)FtpWebRequest.Create(FTPAddress + "/" + Path.GetFileName(filePath));
request.Method = WebRequestMethods.Ftp.UploadFile;
request.Credentials = new NetworkCredential(username, password);
request.UsePassive = true;
request.UseBinary = true;
request.KeepAlive = false;
//Load the file
FileStream stream = File.OpenRead(filePath);
byte[] buffer = new byte[stream.Length];
stream.Read(buffer, 0, buffer.Length);
stream.Close();
//Upload file
Stream reqStream = request.GetRequestStream();
reqStream.Write(buffer, 0, buffer.Length);
reqStream.Close();
MessageBox.Show("Uploaded Successfully");
}
private void btnUpload_Click(object sender, EventArgs e)
{
btnUpload.Enabled = false;
Application.DoEvents();
uploadFile(txtFTPAddress.Text, txtFilePath.Text, txtUsername.Text, txtPassword.Text);
btnUpload.Enabled = true;
}
private void txtFTPAddress_Leave(object sender, EventArgs e)
{
if (!txtFTPAddress.Text.StartsWith("ftp://"))
txtFTPAddress.Text = "ftp://" + txtFTPAddress.Text;
}
private void button1_Click(object sender, EventArgs e)
{
if (openFile1.ShowDialog() == DialogResult.OK)
txtFilePath.Text = openFile1.FileName;
}
}
}
I would have included the source code but I am kind of in a hurry and I need a new copy of winzip to archive before I can add it. Maybe I will post with the complete code for the app in a while. Hope this helps out
Bookmarks
Algorithms and Data Structures
Java tutorials
Algorithms Forum