コード例 #1
0
        private void MenuItem_Click_1(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openFile = new OpenFileDialog();

            openFile.Title  = "Select picture";
            openFile.Filter = "All supported graphics|*.jpg;*.jpeg;*.png|" +
                              "JPEG (*.jpg;*.jpeg)|*.jpg;*.jpeg|" +
                              "Portable Network Graphic (*.png)|*.png";
            if (openFile.ShowDialog() == true)
            {
                string nazwaPliku = Path.GetFileName(openFile.FileName);
                try
                {
                    client2.addFile(File.OpenRead(openFile.FileName));
                    client2.putPicture(client.getID(), Path.GetFileName(openFile.FileName));
                    client.addRecord(openFile.FileName);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "My app", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
            }
        }