c sharp coding for finding picture name
- User
c sharp coding for finding picture name
- Assistant
To find the picture name using C#, you can use the OpenFileDialog class to allow the user to browse and select the desired picture file. Here's an example:
csharpusing System; using System.Windows.Forms; class Program { static void Main() { // Create an instance of the OpenFileDialog class OpenFileDialog openFileDialog = new OpenFileDialog(); // Set the initial directory and filter for picture files openFileDialog.InitialDirectory = "C:\\"; openFileDialog.Filter = "Image Files (*.bmp, *.jpg, *.png)|*.bmp;*.jpg;*.png"; // Show the dialog and check if the user selected a file if (openFileDialog.ShowDialog() == DialogResult.OK) { // Get the selected file name and display it string pictureName = openFileDialog.FileName; Console.WriteLine("Selected picture name: " + pictureName); } else { Console.WriteLine("No picture selected."); } } } - User
c sharp coding for image choosing application
- Assistant
Sure! Here's an example of a simple C# application that allows the user to choose an image file and display it in a PictureBox control:
csharp