<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://www.infopathdev.com:443/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Code</title><link>https://www.infopathdev.com:443/forums/45.aspx</link><description /><dc:language>en</dc:language><generator>CommunityServer 2007 SP3 (Build: 31118.962)</generator><item><title>Re: Get Attachment Name</title><link>https://www.infopathdev.com:443/forums/thread/125265.aspx</link><pubDate>Fri, 31 Mar 2023 17:50:55 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:125265</guid><dc:creator>Rockie</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/125265.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=125265</wfw:commentRss><description>Qazi Anis, I know many Years have passed, but thank You much! :)</description></item><item><title>Re: Get Attachment Name</title><link>https://www.infopathdev.com:443/forums/thread/119467.aspx</link><pubDate>Tue, 17 Jul 2018 16:03:06 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:119467</guid><dc:creator>jd422</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/119467.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=119467</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;I see that there are nice replies for C code (C#, at least).&amp;nbsp; I hope it&amp;#39;s OK for me to give my solution for vbScript in case someone Googles it.&lt;/p&gt;&lt;p&gt;
&lt;code&gt;
&lt;font face="Arial"&gt;Function AttachmentFileName(ByRef node)&lt;br /&gt;&amp;nbsp;Dim nodeValue, i, filenameSize&lt;br /&gt;&amp;nbsp;Dim HexString&lt;/font&gt;&lt;/code&gt;&lt;/p&gt;&lt;p&gt;&lt;code&gt;&lt;font face="Arial"&gt;&amp;nbsp;HexString = &amp;quot;&amp;quot;&lt;/font&gt;&lt;/code&gt;&lt;/p&gt;&lt;p&gt;&lt;code&gt;&lt;font face="Arial"&gt;&amp;nbsp;If(node.text &amp;lt;&amp;gt; &amp;quot;&amp;quot;) Then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;#39;typecast the node to base64 as Infopath doesn&amp;#39;t do this in node definition&lt;br /&gt;&amp;nbsp;&amp;nbsp;node.DataType = &amp;quot;bin.base64&amp;quot; &amp;#39;Doing this will prevent the user from deleting the attachment&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;#39;Change the data type back to &amp;quot;&amp;quot; when done.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;#39;convert base64 node value to binary and store in nodeValue byte array&lt;br /&gt;&amp;nbsp;&amp;nbsp;nodeValue = node.nodeTypedValue&lt;br /&gt;&amp;nbsp;Else&lt;br /&gt;&amp;nbsp;&amp;nbsp;AttachmentFileName = &amp;quot;Nothing attached.&amp;nbsp; First attach a file.&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;Exit Function&lt;br /&gt;&amp;nbsp;End If&lt;/font&gt;&lt;/code&gt;&lt;/p&gt;&lt;p&gt;&lt;code&gt;&lt;font face="Arial"&gt;&amp;nbsp;&amp;#39;Convert ByteArray to HexString&lt;br /&gt;&amp;nbsp;For i = 1 to LenB(nodeValue)&lt;br /&gt;&amp;nbsp;&amp;nbsp;HexString = HexString &amp;amp; Right(&amp;quot;0&amp;quot; &amp;amp; Hex(AscB(MidB(nodeValue, i, 1))), 2)&lt;br /&gt;&amp;nbsp;&amp;nbsp;If(i = 300) Then &amp;#39;Assuming header is no longer than 300 bytes&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;exit for&lt;br /&gt;&amp;nbsp;&amp;nbsp;end if&lt;br /&gt;&amp;nbsp;Next&lt;/font&gt;&lt;/code&gt;&lt;/p&gt;&lt;p&gt;&lt;code&gt;&lt;font face="Arial"&gt;&amp;nbsp;AttachmentFileName = &amp;quot;&amp;quot;&lt;br /&gt;&amp;nbsp;filenameSize = 0&lt;/font&gt;&lt;/code&gt;&lt;/p&gt;&lt;p&gt;&lt;code&gt;&lt;font face="Arial"&gt;&amp;nbsp;&amp;#39;The length of the filenamebuffer is stored on pos 20-24 (byte), which means 41.47 in Hex and 1 as startpos for Arrays&lt;br /&gt;&amp;nbsp;filenameSize = getFilenameSize(HexString,41,47)&lt;/font&gt;&lt;/code&gt;&lt;/p&gt;&lt;p&gt;&lt;code&gt;&lt;font face="Arial"&gt;&amp;nbsp;&amp;#39;Read the filename from position (49 to filenamebuffer * unicode - &amp;quot;\n&amp;quot;) as end char&lt;br /&gt;&amp;nbsp;AttachmentFileName = getFileName(HexString,49,filenameSize*4 + 49 - 2)&lt;br /&gt;&amp;nbsp;node.DataType = &amp;quot;&amp;quot; &amp;#39;This will allow the user to remove the attachment if desired&lt;br /&gt;&amp;nbsp;&amp;#39;MsgBox filename &amp;#39;Uncomment for debugging&lt;br /&gt;End Function&lt;/font&gt;&lt;/code&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;Function getFilenameSize(data, startLoop, stopLoop)&lt;br /&gt;&amp;nbsp;dim k&lt;br /&gt;&amp;nbsp;dim size&lt;/p&gt;&lt;p&gt;&amp;nbsp;for k = startLoop to stopLoop step 2&lt;br /&gt;&amp;nbsp;&amp;nbsp;dim y1&lt;br /&gt;&amp;nbsp;&amp;nbsp;dim y2&lt;br /&gt;&amp;nbsp;&amp;nbsp;dim y3&lt;br /&gt;&amp;nbsp;&amp;nbsp;y1 = Mid(data,k,2)&lt;br /&gt;&amp;nbsp;&amp;nbsp;y2 = CLng(&amp;quot;&amp;amp;h&amp;quot; &amp;amp; y1)&lt;br /&gt;&amp;nbsp;&amp;nbsp;y3 = y3 + Int(y2)&lt;br /&gt;&amp;nbsp;&amp;nbsp;size = y3&lt;br /&gt;&amp;nbsp;next&lt;br /&gt;&amp;nbsp;getFilenameSize = size&lt;br /&gt;End Function&lt;/p&gt;&lt;p&gt;Function getFileName(data, startLoop, stopLoop)&lt;br /&gt;&amp;nbsp;dim k&lt;br /&gt;&amp;nbsp;dim filename&lt;/p&gt;&lt;p&gt;&amp;nbsp;for k = startLoop to stopLoop step 4&lt;br /&gt;&amp;nbsp;&amp;nbsp;dim h1&lt;br /&gt;&amp;nbsp;&amp;nbsp;dim h2&lt;br /&gt;&amp;nbsp;&amp;nbsp;dim h3&lt;br /&gt;&amp;nbsp;&amp;nbsp;h1 = Mid(data,k,2)&lt;br /&gt;&amp;nbsp;&amp;nbsp;h2 = CLng(&amp;quot;&amp;amp;h&amp;quot; &amp;amp; h1)&lt;br /&gt;&amp;nbsp;&amp;nbsp;h3 = Chr(h2)&lt;br /&gt;&amp;nbsp;&amp;nbsp;if(h3 &amp;lt;&amp;gt; &amp;quot;&amp;quot;) then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;filename = filename &amp;amp; Cstr(h3)&lt;br /&gt;&amp;nbsp;&amp;nbsp;end if&lt;br /&gt;&amp;nbsp;next&lt;br /&gt;&amp;nbsp;getFileName = filename&lt;br /&gt;End Function &lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: Get Attachment Name</title><link>https://www.infopathdev.com:443/forums/thread/119429.aspx</link><pubDate>Thu, 12 Jul 2018 15:08:00 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:119429</guid><dc:creator>Hilary Stoupa</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/119429.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=119429</wfw:commentRss><description>The initial response in this thread from Qazi Anis should work in IP 2013 C# code.</description></item><item><title>Re: Get Attachment Name</title><link>https://www.infopathdev.com:443/forums/thread/119427.aspx</link><pubDate>Thu, 12 Jul 2018 00:30:17 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:119427</guid><dc:creator>Jas4Vee</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/119427.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=119427</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;How does the work with InfoPath 2013&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Re: Get Attachment Name</title><link>https://www.infopathdev.com:443/forums/thread/101425.aspx</link><pubDate>Wed, 25 Feb 2015 18:24:34 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:101425</guid><dc:creator>bonjarno</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/101425.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=101425</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;Hi Qazi,&lt;/p&gt;&lt;p&gt;Thanks for the great post - it works well for the filename - but I also need the full pathname - driveletter:\directory\subdirectory1\...\subdirectoryX\filename.ext&lt;/p&gt;&lt;p&gt;&amp;nbsp;Is that possible? Is it in the encoded file somewhere?&lt;/p&gt;&lt;p&gt;&amp;nbsp;I am wondering if the Attachment Control has any attributes itself?&lt;/p&gt;&lt;p&gt;&amp;nbsp;Oh - and I experienced a big&amp;nbsp;shock when my test&amp;nbsp;InfoPath solution worked with your code but then when I added it to my&amp;nbsp;real version that has an External Item Picker&amp;nbsp;(to grab data from BCS), I get an error and&amp;nbsp;have discovered that Browser Based Forms cannot have both EIPs and User Code....Do you have any thoughts or comments on that?&lt;/p&gt;&lt;p&gt;&amp;nbsp;THanks in advance.&lt;/p&gt;&lt;p&gt;Cheers,&lt;/p&gt;&lt;p&gt;John Marno&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Re: Get Attachment Name</title><link>https://www.infopathdev.com:443/forums/thread/101423.aspx</link><pubDate>Wed, 25 Feb 2015 18:17:47 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:101423</guid><dc:creator>bonjarno</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/101423.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=101423</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;Hi - this is a while since your post but I have a situation where I have to be able to harvest the full path name of the attachment - not just the filename, which I have been able to do. Do you have any information about other attributes, how I might get the full pathname, etc? Thx, John Marno&lt;/p&gt;</description></item><item><title>Re: Get Attachment Name</title><link>https://www.infopathdev.com:443/forums/thread/56028.aspx</link><pubDate>Fri, 18 Jun 2010 23:22:59 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:56028</guid><dc:creator>aruna akella</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/56028.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=56028</wfw:commentRss><description>&lt;p&gt;We have &lt;strong&gt;GetAttachmentAttribute&lt;/strong&gt; command in qRules v2.2, which is going to release soon. That command gets a specific attribute(like attribute name, extenstion, size, file) of a file attachment or a picture attachment. That command works on IP 2007, as well as IP 2010.&lt;/p&gt;
&lt;p&gt;stay tuned!&lt;/p&gt;</description></item><item><title>Re: Get Attachment Name</title><link>https://www.infopathdev.com:443/forums/thread/55992.aspx</link><pubDate>Fri, 18 Jun 2010 00:02:23 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:55992</guid><dc:creator>cliffob03</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/55992.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=55992</wfw:commentRss><description>&lt;p&gt;Hi Qazi, I have found that the solution above works great for IP 2007, however I have been unsuccessful in running it in IP 2010.&amp;nbsp; The problem seems to be in the calculation of the&amp;nbsp;filename which is unfortunately needed in my case.&amp;nbsp;&amp;nbsp;Have you seen this, is there any solution that you know of?&lt;/p&gt;
&lt;p&gt;Thanks!&amp;nbsp;&lt;/p&gt;</description></item><item><title>Re: Get Attachment Name</title><link>https://www.infopathdev.com:443/forums/thread/54527.aspx</link><pubDate>Wed, 05 May 2010 07:28:00 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:54527</guid><dc:creator>Qazi Anis</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/54527.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=54527</wfw:commentRss><description>&lt;p&gt;
change the paragraph

            private void DecodeAttachment(BinaryReader theReader)
            {
                byte[] headerData = new byte[FIXED_HEADER];
                headerData = theReader.ReadBytes(headerData.Length);
                fileSize = (int)theReader.ReadUInt32();
                attachmentNameLength = (int)theReader.ReadUInt32() * 2;
                byte[] fileNameBytes = theReader.ReadBytes(attachmentNameLength);
               // byte[] fileNameBytes = theReader.ReadBytes(attachmentNameLength);
                Encoding enc = Encoding.Unicode;
                attachmentName = enc.GetString(fileNameBytes, 0, attachmentNameLength -2  );
                decodeAttachment = theReader.ReadBytes(fileSize);
                

              }
actually you only need to change the line 
                attachmentName = enc.GetString(fileNameBytes, 0, attachmentNameLength -2  );
&lt;/p&gt;</description></item><item><title>Re: Get Attachment Name</title><link>https://www.infopathdev.com:443/forums/thread/54514.aspx</link><pubDate>Wed, 05 May 2010 00:57:14 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:54514</guid><dc:creator>sharepoint99</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/54514.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=54514</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;Hello I am facing kind of similar issue..my problem is that i have a browser enabled infopath 2007 form in that form there is a file attachment control in which users can upload documents nowi want to restrict the file types to be only of doc and pdf ...since selecting allowable file types is not there in browser based forms how do i do that...I got this code from a website but this does&amp;#39;nt work properly..it displays error but it displays for the PDF file also which it should allow..can somebody plz tell me what&amp;#39;s wrong with the code...any help is really very much appreciated..&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp; public class InfopathAttachmentDecoder&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; private const int SP1Header_Size = 20;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; private const int FIXED_HEADER = 16;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; private int fileSize;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; private int attachmentNameLength;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; private string attachmentName;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; private byte[] decodeAttachment;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public InfopathAttachmentDecoder(string theBase64EncodedString)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; { &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; byte[] theData = Convert.FromBase64String(theBase64EncodedString );&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; using(MemoryStream ms = new MemoryStream(theData ) )&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BinaryReader theReader= new BinaryReader(ms);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DecodeAttachment(theReader );&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; private void DecodeAttachment(BinaryReader theReader)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; byte[] headerData = new byte[FIXED_HEADER];&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; headerData = theReader.ReadBytes(headerData.Length);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fileSize = (int)theReader.ReadUInt32();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; attachmentNameLength = (int)theReader.ReadUInt32() * 2;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; byte[] fileNameBytes = theReader.ReadBytes(attachmentNameLength);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // byte[] fileNameBytes = theReader.ReadBytes(attachmentNameLength);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Encoding enc = Encoding.Unicode;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; attachmentName = enc.GetString(fileNameBytes, 0, attachmentNameLength&amp;nbsp; );&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; decodeAttachment = theReader.ReadBytes(fileSize);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public string Filename&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; get { return attachmentName; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public byte[] DecodedAttachment&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; get { return decodeAttachment; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public void image_Validating(object sender, XmlValidatingEventArgs e)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(!e.UndoRedo &amp;amp;&amp;amp; e.Operation == XmlOperation.ValueChange)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; string base64string = e.Site.Value;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(!string.IsNullOrEmpty(base64string))&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; InfopathAttachmentDecoder decoder=&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; new InfopathAttachmentDecoder(base64string);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; string filename = decoder.Filename;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; byte[] data= decoder.DecodedAttachment;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; string fileExtension = filename.Substring(filename.IndexOf(&amp;quot; . &amp;quot;) + 1);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(fileExtension.ToUpper()!= &amp;quot;PDF&amp;quot;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; e.ReportError(e.Site,false,&amp;quot;Only pdf are allowed&amp;quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;</description></item><item><title>Re: Get Attachment Name</title><link>https://www.infopathdev.com:443/forums/thread/54500.aspx</link><pubDate>Tue, 04 May 2010 16:38:33 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:54500</guid><dc:creator>jnm0016</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/54500.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=54500</wfw:commentRss><description>&lt;p&gt;I am trying to attach a variaty of file types (mainly pdf, jpeg, word, excel and powerpoint). And it appears that the error only happens when previewing from the design view so I am not sure how much of an issue it is. I am hoping that it does not cause issues further down the process.&lt;/p&gt;
&lt;p&gt;I am now trying to get the filename for an attachment control in a repeating table and running into issues. Will beg for help if I get completely stuck. (Or run out of time)&lt;/p&gt;</description></item><item><title>Re: Get Attachment Name</title><link>https://www.infopathdev.com:443/forums/thread/54473.aspx</link><pubDate>Tue, 04 May 2010 02:34:47 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:54473</guid><dc:creator>Jimmy</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/54473.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=54473</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;Are you trying to use this with image files?&amp;nbsp; I believe that images are not stored with the InfoPath header information as other file types are, and will cause erratic behavior in the above code.&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: Get Attachment Name</title><link>https://www.infopathdev.com:443/forums/thread/54465.aspx</link><pubDate>Mon, 03 May 2010 21:12:59 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:54465</guid><dc:creator>jnm0016</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/54465.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=54465</wfw:commentRss><description>&lt;p&gt;First, I am relatively new to the Infopath world and programing in general but&amp;nbsp;I would like to say&amp;nbsp;thank you for sharing this bit of code. Second, I have it working (mostly) but I get an error when it runs. It looks like it is trying to read past the EOF. What I am trying to do is fill in a read-only field on the form with the name of the attachment when the file is attached.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;Any help would be appreciated.&lt;/p&gt;</description></item><item><title>Re: Get Attachment Name</title><link>https://www.infopathdev.com:443/forums/thread/53896.aspx</link><pubDate>Tue, 20 Apr 2010 13:03:25 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:53896</guid><dc:creator>Qazi Anis</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/53896.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=53896</wfw:commentRss><description>&lt;font size="2"&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;string&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; attachedFile = &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;string&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;.Empty;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;for&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; (&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;int&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; i = 1; i &amp;lt;= dml.length; i++)&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; 
&lt;p&gt;{&lt;/p&gt;attachedFile = thisXDocument.DOM.selectSingleNode(&lt;/font&gt;&lt;font color="#800000" size="2"&gt;&lt;font color="#800000" size="2"&gt;&amp;quot;/my:myFields/my:group1/my:group2[&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;+i+&lt;/font&gt;&lt;font color="#800000" size="2"&gt;&lt;font color="#800000" size="2"&gt;&amp;quot;]/my:field4&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;).text;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; 
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/font&gt;&lt;font color="#008080" size="2"&gt;&lt;font color="#008080" size="2"&gt;Encoding&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; _encoding = &lt;/font&gt;&lt;font color="#008080" size="2"&gt;&lt;font color="#008080" size="2"&gt;Encoding&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;.Unicode;&lt;/p&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;using&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; (&lt;/font&gt;&lt;font color="#008080" size="2"&gt;&lt;font color="#008080" size="2"&gt;MemoryStream&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; _memoryStream = &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;new&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#008080" size="2"&gt;&lt;font color="#008080" size="2"&gt;MemoryStream&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;(&lt;/font&gt;&lt;font color="#008080" size="2"&gt;&lt;font color="#008080" size="2"&gt;Convert&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;.FromBase64String(attachedFile)))&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; 
&lt;p&gt;{&lt;/p&gt;&lt;/font&gt;&lt;font color="#008080" size="2"&gt;&lt;font color="#008080" size="2"&gt;BinaryReader&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; _theReader = &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;new&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#008080" size="2"&gt;&lt;font color="#008080" size="2"&gt;BinaryReader&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;(_memoryStream);&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; 
&lt;p&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;byte&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;[] _headerData = _theReader.ReadBytes(16);&lt;/p&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;int&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; _fileSize = (&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;int&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;)_theReader.ReadUInt32(); &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;int&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; _attachmentNameLength = (&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;int&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;)_theReader.ReadUInt32() * 2;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; 
&lt;p&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;byte&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;[] _fileNameBytes = _theReader.ReadBytes(_attachmentNameLength);&lt;/p&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;string&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; fileName = _encoding.GetString(_fileNameBytes, 0, _attachmentNameLength - 2);&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;thisXDocument.DOM.selectSingleNode(&lt;/font&gt;&lt;font color="#800000" size="2"&gt;&lt;font color="#800000" size="2"&gt;&amp;quot;/my:myFields/my:group1/my:group2[&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; + i + &lt;/font&gt;&lt;font color="#800000" size="2"&gt;&lt;font color="#800000" size="2"&gt;&amp;quot;]/my:field1&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;).text = fileName;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; 
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;&lt;/font&gt;</description></item><item><title>Re: Get Attachment Name</title><link>https://www.infopathdev.com:443/forums/thread/53875.aspx</link><pubDate>Mon, 19 Apr 2010 23:15:20 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:53875</guid><dc:creator>Lawson</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/53875.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=53875</wfw:commentRss><description>&lt;p&gt;Qazi,&lt;/p&gt;
&lt;p&gt;Thank you for your help in this post.&lt;/p&gt;
&lt;p&gt;I have one more question. The attachment field that I am getting the attachment&amp;nbsp;name from is in a repeating section. The solution you gave me above works well. But it only gets the name of one document in the repeating section. &lt;/p&gt;
&lt;p&gt;How can I use the solution above to get all the names?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;Thanks,&lt;/p&gt;
&lt;p&gt;-Lawson&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item></channel></rss>