Hi Kulabhishek,
I don't know how you can open a folder with right click. I have done such case to right click a file to open with my own application. In achieve this, I should modify the Main method.
The Main method in a Winform application does not have any parameter, I should change it to "static void Main(string[] args)" just like it in a console application. When I right click a file to open it, the full name of the file will be transmitted to the Main method. Use this code
| if(args.Length>0) |
| { |
| MessageBox.Show(args[0]); |
| } |
You can get the path and file name.
| [STAThread] |
| staticvoidMain(string[]args) |
| { |
| Application.EnableVisualStyles(); |
| Application.SetCompatibleTextRenderingDefault(false); |
| if(args.Length>0) |
| { |
| //Getthepathandfilename |
| MessageBox.Show(args[0]); |
| } |
| Application.Run(newForm6()); |
| } |
As for the "Directory.GetCurrentDirectory()" method. The current directory is distinct from the original directory, which is the one from which the process was started. So it always show the parent folder.
If I misunderstand something, please feel free to tell me.
Sincerely,
Kira Qian
Please mark the replies as answers if they help and unmark if they don't.