I'm developing a VSPackage in C#, and I would like to know how to get the current file, when only a single file (or several files are opened in Visual Studio).
All works fine when there is a hierarchy (a real solution opened). But when I open a single file in Visual Studio, I cannot get the curren selection. I mean open Visual Studio (without solution) and select File
-> Open
-> File
.
I need to get one of these: itemid, documentCookie, mkDocumentName or whatever.
I tried the following:
IVsMonitorSelection.GetCurrentSelection()
-> It always retrieve the solution item id without hierarchy (Intpr.Zero)IVsSelectionEvents
-> I tried to listen the selection event, the new itemId is always the solution itemidRunningDocumentTable
-> Well, I'm close to find the solution, because I can enumerate the opened files, but I'm not sure how to determine which is the current one.