title: How to convert C# string[] to System.IntPtr?
body: <p>I need to use a native dll struct in my application.
  struct da_i2k_input_file_info in the dll .h file is</p>
  
  <pre><code>struct DA_I2K_EXPORT_API da_i2k_input_file_info {
    const WDCHAR *  image_path;
    const WDCHAR ** image_files;
    int             num_images;
  };
  </code></pre>
  
  <p>and this is what user code might look like if written in C++</p>
  
  <pre><code>in_file_info.num_images = 3;
  in_file_info.image_files = new const WDCHAR*[in_file_info.num_images];
  in_file_info.image_files[0] = WSTR("IMG_8670.JPG");
  in_file_info.image_files[1] = WSTR("IMG_8671.JPG");
  in_file_info.image_files[2] = WSTR("IMG_8672.JPG");
  </code></pre>
  
  <p>But this C# code</p>
  
  <pre><code>[StructLayout(LayoutKind.Sequential)]
  public struct da_i2k_input_file_info
  {
      [MarshalAs(UnmanagedType.LPTStr)]
      public string image_path;
      public IntPtr image_files;
      public int num_images;
  }
  
  var openFileDialog = new OpenFileDialog{Multiselect = true};
  da_i2k_input_file_info in_file_info;
  in_file_info.image_path = null; // use full path in .image_files
  in_file_info.num_images = openFileDialog.FileNames.Length;
  in_file_info.image_files = openFileDialog.FileNames;
  </code></pre>
  
  <p>Causes this error </p>
  
  <blockquote>
    <p>Cannot implicitly convert type 'string[]' to 'System.IntPtr'</p>
  </blockquote>
  
  <p>Casting openFileDialog.FileNames as IntPtr does not help.
  How can I load in_file_info.image_files from openFileDialog.FileNames?</p>
  
  <p>Edit: <a href="http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/8a84708d-255b-4010-94d8-cdb5205a0a0c/" rel="nofollow">OP cross posted this here</a></p>