Search Unity

replace text in a .docx file

Discussion in 'Scripting' started by BigBGros, Sep 23, 2014.

  1. BigBGros

    BigBGros

    Joined:
    Aug 30, 2013
    Posts:
    21
    Hi all,

    I'm trying to replace a text from a word 2010 file (.docx) and i've some issues when running the game, I'm using DOCX managed library, could be found here.

    Here is the code:

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using Novacode;
    4. using System.IO;
    5.  
    6. public class doc : MonoBehaviour
    7. {
    8.     void Start()
    9.     {
    10.         stringReplace (Application.persistentDataPath + "/OSMLAB Cervical.docx", "NICKNAME", "myname");
    11.     }
    12.  
    13.     void stringReplace(string file, string textToReplace, string text)
    14.     {
    15.         DocX document = DocX.Load (file);
    16.         document.ReplaceText (textToReplace, text);
    17.         document.Save ();
    18.         document.Dispose ();
    19.     }
    20. }
    the problem is when play start, it throws this exception:

    I've tried in Visual C# with exact code and it works perfect.

    it seems that is an assembly problem, how can i solve this?

    Thanks in Advance.
     
  2. BigBGros

    BigBGros

    Joined:
    Aug 30, 2013
    Posts:
    21
    any suggestions about?

    Thanks.