コード例 #1
0
        private void btnUpload_Click(object sender, EventArgs e)
        {
            if (comboBox1.SelectedItem == null)
            {
                MessageBox.Show(@"You need to select crypto algorithm before uploading", @"Warning",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            using (OpenFileDialog ofd = new OpenFileDialog
            {
                InitialDirectory = _directoryPath,
                Title = "Select File to Upload",

                CheckFileExists = true,
                CheckPathExists = true,

                Filter = "txt files (*.txt)|*.txt|Image (*.jpg)|*.jpg|Image (*.png)|*.png|Video (*.mp4)|*.mp4|Video (*.avi)|*.avi|Audio (*.wav)|*.wav|Audio (*.mp3)|*.mp3|Document (*.doc)|*.doc|Document (*.pdf)|*.pdf|Document (*.xml)|*.xml|Document (*.json)|*.json|ZIP (*.zip)|*.zip|Excel (*.xls)|*.xls",
                FilterIndex = 1,
                RestoreDirectory = true,

                ReadOnlyChecked = true,
                ShowReadOnly = true
            })
            {
                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    using (LoadForm lf = new LoadForm(ofd.FileName, _client, ofd.SafeFileName, comboBox1.Text, _userName))
                    {
                        try
                        {
                            lf.ShowDialog();
                        }
                        catch (Exception exception)
                        {
                            Console.WriteLine(exception);
                        }
                    }
                    GetAllFiles();
                }
                ofd.Reset();
            }
        }