XSN模板创建InfoPath表单

XSN模板创建InfoPath表单

本文介绍了如何以编程方式从InfoPath XSN模板创建InfoPath表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个从SharePoint服务器上存在的XSN模板创建InfoPath实例表单的解决方案,我正在使用此方法,但这会在服务器的临时目录中提取模板文件,而我们可能不会这样做拥有写权限.有更好的解决方案吗?

I need a solution that creates an InfoPath instance form from an XSN template that exists on a SharePoint server, I am using this approach but this extracts template files on temp directory of server that we may not have write permission to. Is there better solution for this?

推荐答案

您只需将CAB库更改为可以将模板文件提取到内存的库,就像这样,

You just change the CAB-library, to one that can extract the template file to memory, as this one,

从内存中的.CAB存档或InfoPath XSN文件中提取的最少C#代码

然后调用myCab.ExtractFile("template.xml", out buffer, out bufferLen);

完整的代码看起来像

private byte[] GetXmlForm(SPDocumentLibrary list) {
  byte[] data = null;
  SPFile file = list.ParentWeb.GetFile(list.DocumentTemplateUrl);


  Stream fs = file.OpenBinaryStream();
  try {
    data = new byte[fs.Length];
    fs.Read(data, 0, data.Length);
  } finally {
    fs.Close();
  }

  byte[] buffer;
  int bufferLen;
  CabExtract cab = new CabExtract(data);
  cab.ExtractFile("template.xml", out buffer, out bufferLen);

  return buffer;
}

这篇关于如何以编程方式从InfoPath XSN模板创建InfoPath表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-22 22:22