title: Embedding Python in C# via resources
body: <p>I have been working on a problem for a while now which I cannot seem to resolve so I need some help! The problem is that I am writing a program in C# but I require a function from a Python file I created. This  in itself is no problem:</p>
  
  <pre><code>...Usual Stuff
  
  using IronPython.Hosting;
  using IronPython.Runtime;
  using Microsoft.Scripting;
  using Microsoft.Scripting.Hosting; 
  
  namespace Program
  {
      public partial class Form1 : Form
      {
          Microsoft.Scripting.Hosting.ScriptEngine py;
          Microsoft.Scripting.Hosting.ScriptScope s;
          public Form1()
          {
              InitializeComponent();
  
              py = Python.CreateEngine(); // allow us to run ironpython programs
              s = py.CreateScope(); // you need this to get the variables
  
          }
  
          private void doPython()
          {
              //Step 1: 
              //Creating a new script runtime             
              var ironPythonRuntime = Python.CreateRuntime();
  
              //Step 2:
              //Load the Iron Python file/script into the memory
              //Should be resolve at runtime
               dynamic loadIPython = ironPythonRuntime.;
  
               //Step 3:
               //Invoke the method and print the result
               double n = loadIPython.add(100, 200);
               numericUpDown1.Value = (decimal)n;
           }
      }
  }
  </code></pre>
  
  <p>However, this requires for the file 'first.py' to be wherever the program is once compiled. So if I wanted to share my program I would have to send both the executable and the python files which is very inconvenient. One way I thought to resolve this is by adding the 'first.py' file to the resources and running from there... but I don't know how to do this or even if it is possible.</p>
  
  <p>Naturally the above code will not work for this as .UseFile method takes string arguments not byte[]. Does anyone know how I may progress?</p>