How do I: Open a file outside the project

Hi

I have a string containing a file name, e.g. "c:\temp\myfile.txt". It is
not part of the current project.

How do I open this file in the text editor?

Thanks
--Jakob


2 comments
Comment actions Permalink

Hello Jakob,

in 3.0 we've added an overloaded method

EditorManager.OpenProjectFile(string fileName, bool activate)

exactly for that. In 2.x you can use VS's automation API from ReSharper plugin
as follows (note that you will have to
add a reference to EnvDTE assembly to your project):

_DTE dte = VSShell.Instance.ApplicationObject;
dte.ItemOperations.OpenFile(fileName, Constants.vsViewKindTextView);
// get ReShaper's project item
IProjectFile projectFile = SolutionManager.Instance.CurrentSolution.FindProjectItemByLocation(new
FileSystemPath(fileName)) as IProjectFile;


Dmitry Shaporenkov
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"


Hi

I have a string containing a file name, e.g. "c:\temp\myfile.txt". It
is not part of the current project.

How do I open this file in the text editor?

Thanks
--Jakob



0
Comment actions Permalink

Hello Dmitry,

It works - great!

Thanks
--Jakob

Hello Jakob,

in 3.0 we've added an overloaded method

EditorManager.OpenProjectFile(string fileName, bool activate)

exactly for that. In 2.x you can use VS's automation API from
ReSharper plugin
as follows (note that you will have to
add a reference to EnvDTE assembly to your project):
_DTE dte = VSShell.Instance.ApplicationObject;
dte.ItemOperations.OpenFile(fileName,
Constants.vsViewKindTextView);
// get ReShaper's project item
IProjectFile projectFile =
SolutionManager.Instance.CurrentSolution.FindProjectItemByLocation(new
FileSystemPath(fileName)) as IProjectFile;
Dmitry Shaporenkov
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

>> Hi
>>
>> I have a string containing a file name, e.g. "c:\temp\myfile.txt". It
>> is not part of the current project.
>>
>> How do I open this file in the text editor?
>>
>> Thanks
>> --Jakob


0

Please sign in to leave a comment.