0

How do i automatic load an image in my C# program with open with( from left click of the mouse).

I've developed a program with windows forms that open images and show them in a image box (because i hate the image viewer from windows 10, is too slow) so i decided to start this easy project. But after finished everything i've decided to improve my program a little. My idea is, if i click, lets take for example, on an excel file in pc, the excel program open and automaticly load that file that i clicked on, i dont need to click in file and after this click on menu, file, load and choose a file to load. I want to do exact the same, but with png and jpg files. I've tried to do the same, but my program don't automatic load the image file, because i don't know how to get a path from a random jpg that i click on to open. Somebody can help me, i'm new programming in C#.

22nd Mar 2021, 4:44 AM
vinicius mendes salvajoli
vinicius mendes salvajoli - avatar
3 Antworten
0
You will want to change the default app association for .png and .jpg files. Here is one way to do it: 1. In Windows 10 File Explorer right-click on an image file that you want to associate with your viewer. 2. Select Open with > 3. Select Choose another app 4. Click on More apps 5. Put a check mark in the box for Always use this app to open .[xxx] files 6. Click on Look for another app on this PC 7. Navigate to your viewer, click on it and press Open. Hereafter, double-clicking on the same file type should open with your viewer program instead of Microsoft Photos.
23rd Mar 2021, 9:20 PM
Brian
Brian - avatar
0
I've already did this and unfortunally, this only opens my application when i click in a jpg or png file, what i'm looking for is how to open and automatic load. If i could get the path from the last file that i clicked on from an history open file log, it will be something simple. But i really don't know where i can find this. But thanks anyway😉
24th Mar 2021, 10:30 PM
vinicius mendes salvajoli
vinicius mendes salvajoli - avatar
0
Windows adds the path\filename to the command line. Your program needs to read the command line arguments passed into main. This link should give a quick start toward that end. https://www.c-sharpcorner.com/article/access-command-line-arguments-in-C-Sharp/
24th Mar 2021, 10:42 PM
Brian
Brian - avatar