ikas-mc / ContextMenuForWindows11

Add Custom Context Menu For Windows11
GNU Lesser General Public License v3.0
1.85k stars 90 forks source link

The path to the folder #116

Closed ivevkz closed 5 months ago

ivevkz commented 5 months ago

hi, I'm a novice programmer, I don't understand how to get the path of the folder where the click was made I need to get the path so that I can then work with it in visual studio C# I tried using json and the path parameter, but something doesn’t work, or I’m doing something wrong, please tell me Thank you!

ikas-mc commented 5 months ago

i don't understand what you're going to do.

Can you add more descriptions?

ivevkz commented 5 months ago

I'm making an application that will create directories of folders and I need to get the path from your application that is, I install my application into your application I go to any folder, right-click, select my application and then I need to get from your application the path to the root folder where the click was made, and transfer it to my application in order to create my own folders I hope you understand)

ikas-mc commented 5 months ago

What type of application, uwp or win32? Can you add some screenshots?

ivevkz commented 5 months ago

Screenshot 2024-03-31 154133 here I tried to get the path via json

yes win32

ikas-mc commented 5 months ago

This doesn't work the arguments are dynamically generated and then passed in via the startup arguments which need to be received in the main method

https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/program-structure/main-command-line

Program.cs

namespace PathTest
{
    internal static class Program
    {

        [STAThread]
        static void Main(string[] args) //read path from here 
        {
            ApplicationConfiguration.Initialize();
            Application.Run(new Form1(args.FirstOrDefault("no args")));
        }
    }
}

Form1.cs

namespace PathTest
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        public Form1(string path)
        {
            InitializeComponent();
            label1.Text = path;
        }
    }
}

Test


PathTest.exe  test

Menu

{
    "title": "Win Form Test",
    "exe": "\"F:\\PathTest.exe\"",
    "param": "\"{path}\"",
    "icon": "\"F:\\PathTest.exe\",0",
    "index": 0,
    "acceptDirectory": true,
    "acceptExts": "*",
    "acceptFileFlag": 1,
    "acceptFileRegex": "",
    "acceptMultipleFilesFlag": 0,
    "pathDelimiter": "",
    "paramForMultipleFiles": ""
}
ivevkz commented 5 months ago

thanks

ivevkz commented 5 months ago

it worked, I couldn't do it for a week, thank you very much