Veröffentlicht 18. Mai 201015 j Hey, okay, ich sthee nun vor meiner letzten Hürde Ich hole mir mit einem openFileDialog den Pfad zu einem bestimmten Ordner, lese dann den Ordner + Unterordner ein und schmeiß ihn in ein Array: string[] filePaths = Directory.GetFiles(pathToFolder, "*.*", SearchOption.AllDirectories); Array files = filePaths.ToArray(); pathToFolder wird gefüllt durch: private void btnSetDirectory_Click(object sender, EventArgs e) { openFileDialog1.ShowDialog(); pathToSetupPHP = openFileDialog1.FileNames[0].ToString(); pathToFolder = Path.GetDirectoryName(pathToSetupPHP).ToString(); } Wie kriege ich nun sämtliche Dateien auf den FTP gekloppt? Einer meiner Versuche: private void btnStart_Click(object sender, EventArgs e) { try { if (MySQLSuccess == true && FTPSuccess == true && pathToSetupPHP != "" && pathToFolder != "") { progressBar.Value = 0; btnMySQLCheck.Enabled = false; btnMySQLReset.Enabled = false; btnFTPCheck.Enabled = false; btnFTPReset.Enabled = false; string[] filePaths = Directory.GetFiles(pathToFolder, "*.*", SearchOption.AllDirectories); Array files = filePaths.ToArray(); //Array files = Directory.GetFileSystemEntries(pathToFolder); FtpWebRequest request = (FtpWebRequest)FtpWebRequest.Create("ftp://" + tbFTPHost.Text + "/" + filePaths); if (cbPassiveMode.Checked == true) { request.UsePassive = true; } else if (cbPassiveMode.Checked == false) { request.UsePassive = false; } if (cbKeepAlive.Checked == true) { request.KeepAlive = true; } else if (cbKeepAlive.Checked == false) { request.KeepAlive = false; } if (cbUseBinary.Checked == true) { request.UseBinary = true; } else if (cbUseBinary.Checked == false) { request.UseBinary = false; } request.Method = WebRequestMethods.Ftp.UploadFile; request.Credentials = new NetworkCredential(tbFTPUsername.Text, tbFTPPassword.Text); FtpWebResponse response = (FtpWebResponse)request.GetResponse(); // dateien auf 100 für progressbar // uploading request.Abort(); response.Close(); } else if (MySQLSuccess == false && FTPSuccess == true) { // Please make sql test first MessageBox.Show("Please make the SQL-Test first!", "Slow down ;)", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (MySQLSuccess == true && FTPSuccess == false) { // please make ftp test first MessageBox.Show("Please make the FTP-Test first!", "Slow down ;)", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (MySQLSuccess == false && FTPSuccess == false) { MessageBox.Show("Please check FTP and MySQL first!", "Slow down ;)", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (pathToFolder == "" || pathToSetupPHP == "") { MessageBox.Show("Set the extracted Directory first!", "Slow down ;)", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Something somewhere went terribly wrong...", "Woha!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { rtbLog.Text += ex.Message.ToString(); } } Danke und liebe Grüße SeToY
Archiv
Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.