Click here to Skip to main content
15,868,016 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I try to run the code, it doesnt tell the format but closes immediately, any ideas?
The path is correct as it some times flashes the format and then closes



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;


namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
              try {
            string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\temp\mybmp.jpg";

        Bitmap image = new Bitmap(path, true);

        Console.WriteLine(image.PixelFormat);


 }
              catch
              {
                  System.Console.WriteLine("Something broke during the read!");
              }
        }


What I have tried:

I added the correct reference but still not working, what do you think is the problem?
Posted
Updated 6-Feb-20 13:14pm
v2

1 solution

If you do not want it to close automatically, you can add
C#
Console.WriteLine("Press a key...");
Console.ReadKey();
at the end of the Main method.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900