iis - Edit file from inetpub folder in wix custom action -


i have reffered this question need edit file during wix installation not xml file. deploying web site through wix , need make changes in 1 file according user input.

below custom actions

<customaction id="customactionid_data" property="custactionid" value="fileid=[#filbefef0f677712d0020c7ed04cb29c3bd];myprop=[myprop];"/>  <customaction id="custactionid"       execute="deferred"       impersonate="no"       return="ignore"       binarykey="customactions.dll"       dllentry="editfile" /> 

and below code in custom action.

string prop= session.customactiondata["myprop"];     string path = session.customactiondata["fileid"]; streamreader f = file.opentext(path); string data = f.readtoend(); data = regex.replace(data, "replacethistext", prop); file.writealltext(path, data);  // throws exception. 

as under iiss intetpub folder action throws error file being used process. solutions?

if need know execution sequence, after installfiles site not yet started files copied.

<installexecutesequence>   <custom action="customactionid_data" before="custactionid">not remove</custom>   <custom action="custactionid" after="installfiles">not remove</custom> </installexecutesequence> 

okay, got solved. neither wix issue nor execution sequence. in code above have opened stream read text , did not dispose after reading, that's holding resource. changed code below , working fine.

string data = ""; string prop= session.customactiondata["myprop"];     string path = session.customactiondata["fileid"]; using(streamreader f = file.opentext(path)) // disposed streamreader properly. {     data = f.readtoend();     data = regex.replace(data, "replacethistext", prop); } file.writealltext(path, data);  

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -