Пример #1
0
        /// <summary>
        /// It handles the ShareFolder button's click event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ShareFolder_Click(object sender, EventArgs e)
        {
            try
            {
                OpenFileDialog open = new OpenFileDialog();
                open.Filter      = "All|*.*";
                open.Multiselect = true;
                open.Title       = "It selects the share folder for the FTP server.";
                if (open.ShowDialog() != System.Windows.Forms.DialogResult.Cancel)
                {
                    List <UploadData> upload = new List <UploadData>();
                    foreach (string file in open.FileNames)
                    {
                        if ((new System.IO.FileInfo(file)).Length > 100000000)
                        {
                            MessageBox.Show("The file '" + file + "' size is more than 100MB, Please select a smaller file.", "FTP File Sharing", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            continue;
                        }
                        UploadData data = new UploadData();
                        data.Filename = file.Split('\\')[file.Split('\\').Length - 1];
                        data.File     = System.IO.File.ReadAllBytes(file);
                        upload.Add(data);
                    }

                    Server.Upload(MachineInfo.GetJustIP(), upload);
                }
            }
            catch (RemotingException re)
            {
                MessageBox.Show(re.Message, "FTP File Sharing", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "FTP File Sharing", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                Refresh_Click(null, null);
            }
        }