Hello,
I'mcurrently developping a customized control which extends "MenuStrip". This class isinside a Class Library.
I'd like to create a file related to the control when it is dropped on the form.
Example:
public class CustomizedMenu : MenuStrip
{
protected override void OnControlAdded(ControlEventArgs e)
{
base.OnControlAdded(e);
// Create file
...
try
{
// Get project path
..
// Open or Create file
FileStream fs = File.Open(path + "/xml/"+ this.Name, FileMode.OpenOrCreate);
...
// Close the stream
fs.Close();
}catch(Exception)
{
throw;
}
}
}
Ibuild the library DLL.
Then I create a new project and add this library. I drag and drop the customized control on the form and this should create the file.
But it doesn't, because the path to the project where the file should be createdis wrong.
I don't know how to get the current project path from the library.
At this moment I can only get the path of the library project, or the path of its assembly, but not the path of the current project in which the control's added.
How toretrieve it ?
I've tried Assembly.GetCallingAssembly(), Assembly.GetEntryAssembly(), etc.. no luck.
This is what I want:
1) Create a new project
2) Import the DLL as reference
3) Drag'n Drop the control on the form
4) It creates a file inside the current project
5) It refresh the current project Treeview (on the right by default)
I don't know how to do the step 5 either...
Please help me :-)
Thanks