title: How to draw an image in c# with path stored in a variable
body: <pre><code>private string path;
  
  public string Path
  {
      get { return path; }
      set { path = value; }
  }
  
  public override void Draw(Graphics.IGraphicsSurface g)
  {
      //some code here
  }
  </code></pre>
  
  <p>I need to get the image stored at the location <code>path</code> on my file system and draw it on the surface, <code>g</code>, using the <code>DrawImage()</code> function.</p>
  
  <p>EDIT:
  The first parameter being passed to <code>DrawImage()</code> must be a string <br>
  <code>public void DrawImage(string image, float x, float y)</code> <br>
  OR file Stream <br>
  <code>public void DrawImage(Stream imageStream, float x, float y)</code> <br><br> </p>
  
  <pre><code>public void DrawImage(string image, float x, float y)
  {
      try
      {
          if (File.Exists(image))
          {
              Stream stream = new FileStream(image, FileMode.Open);
              DrawImage(stream, new Graphics.Point(x, y));
          }
      }
      catch(Exception)
      {
      }
  }
  </code></pre>