Add-in trouble with indent when inserting two lines of code


i using studio add-in add 2 lines of code in source document. indent not respected on second line. how can indent properly.

textselection objsel = (envdte.textselection)(_applicationobject.activedocument.selection);

string firstline = "//modification de : " + system.environment.username + " version ??? - " + datetime.now.tostring();

string secondline = "//appel# ";

if (system.io.file.exists(@"p:\maximum.net\maximum\activecall.txt"))

{

//get file text

system.io.streamreader re = system.io.file.opentext(@"p:\maximum.net\maximum\activecall.txt");

secondline = secondline + re.readtoend();

secondline = secondline.trim();

}

string finaloutput = firstline + " \n" + secondline;

objsel.insert(finaloutput, system.convert.toint32(vsinsertflags.vsinsertflagsinsertatend));

 

finally got wokring using collapse method;

final code looks this:

textselection objsel = (envdte.textselection)(_applicationobject.activedocument.selection);

string firstline = "//modification de : " + system.environment.username + " version ??? - " + datetime.now.tostring();

string secondline = "//appel# ";

if (system.io.file.exists(@"p:\maximum.net\maximum\activecall.txt"))

{

//get file text

system.io.streamreader re = system.io.file.opentext(@"p:\maximum.net\maximum\activecall.txt");

secondline = secondline + re.readtoend();

secondline = secondline.trim();

}

objsel.text = firstline + "\n";

objsel.collapse();

objsel.text = secondline;

objsel.collapse();



Archived Forums V  >  Visual C# IDE



Comments

Popular posts from this blog

Azure DocumentDB Owner resource does not exist

job syspolicy_purge_history job fail in sqlserver 2008

Trying to register with public marketplace error with 'Get-AzureStackStampInformation'