Hi Clay
Thanks for your reply.
actually I only want to set rights & expiry date to an existing files only.No new forms.
for this I changed my code a little bit but its still giving some problem.The problem area is line
oDoc1 = (_XDocument3)oWord.XDocuments.Open(infoFileName, (int)XdDocumentVersionMode.xdCanOpenInReadOnlyMode);
Its throwing an exception here saying "{"InfoPath cannot open the following file: D:\\Test\\2.xsn.\nThe file is not a valid XML file.\n\nThe form contains XML that cannot be parsed:\nAn invalid character was found in text content.\r\n\nLine 1, Position 5\nMSCF\n----^\n"}"
This same code is working fine for excel,word & powerpoint files.
Please tell me where I am wrong.I am pasting my latest code here.
object infoFileName = "D:\\Test\\2.xsn";
Microsoft.Office.Interop.InfoPath.
_XDocument3 oDoc1;
object
exp = MsoPermission.msoPermissionPrint;Microsoft.Office.Interop.InfoPath.Application oWord = new Microsoft.Office.Interop.InfoPath.Application();
oDoc1 = (
_XDocument3)oWord.XDocuments.Open(infoFileName, (int)XdDocumentVersionMode.xdCanOpenInReadOnlyMode);
oDoc1.Permission.Add( username
, MsoPermission.msoPermissionRead, dtExpireDate);