Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[C#] Files aus Array hochladen

Empfohlene Antworten

Veröffentlicht

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.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.