I have four columns and I've added a checkbox column to a DataGridView in my C# form. I have got the selected row values also as below:
private void button3_Click(object sender, EventArgs e)
{
List<DataGridViewRow> rows_with_checked_column = new List<DataGridViewRow>();
foreach (DataGridViewRow row in dataGridView1.Rows)
{
if (Convert.ToBoolean(row.Cells[dataGridView1.Columns[1].Name].Value) == true)
{
rows_with_checked_column.Add(row);
}
}
Below is the code that I have for FTP
string ftpfullpath = @"ftp://" + IPAddress + "/C:/ADX_IPGM/SVIBM.JAR";
string ftpusername = "stcprc";
string ftppassword = "pos9$2";
string source = "d:\ftp.txt";
textBox1.AppendText(System.Environment.NewLine + "Connecting to Controller " + rows_with_checked_column);
FtpWebRequest ftp = (FtpWebRequest)FtpWebRequest.Create(ftpfullpath);
ftp.Credentials = new NetworkCredential(ftpusername, ftppassword);
textBox1.AppendText(System.Environment.NewLine + "User " + ftpusername + " Logged in to Controller " + rows_with_checked_column);
ftp.KeepAlive = true;
ftp.UseBinary = true;
ftp.Method = WebRequestMethods.Ftp.UploadFile;
FileStream fs = File.OpenRead(source);
byte[] buffer = new byte[fs.Length];
fs.Read(buffer, 0, buffer.Length);
fs.Close();
Stream ftpstream = ftp.GetRequestStream();
ftpstream.Write(buffer, 0, buffer.Length);
ftpstream.Close();
success_count += 1;
label1.Text = "Successful Transfers (" + success_count + ")";
textBox1.AppendText(System.Environment.NewLine + "File Transferred successfully!");
Next I need help to loop it with the selected rows by referring the IP address column "URL".