I have done this using this code.
http://support.microsoft.com/kb/892730

Signature
Thanks
Clay Fox
Qdabra Software
http://www.qdabra.com
InfoPathDev.Com
The Largest InfoPath Forum in the World
http://www.infopathdev.com
> Using InfoPath 2007, I would like to write an attached file to my local
> drive using VB.net within the form. As the attachments are encoded as base64,
[quoted text clipped - 5 lines]
>
> Any help would be appreciated.
kb at donovanhill - 16 Nov 2007 03:16 GMT
Hi Clay,
Thanks for your reply, the code example link that you gave is for C# and I
do not have Visual Studio .NET, only VS for Apps which runs with InfoPath
2007.
Will the C# encoder class that you have work with VB.net? could I just
reference it & use it?
Not sure how to make this work??
Thanks

Signature
kb
> I have done this using this code.
> http://support.microsoft.com/kb/892730
[quoted text clipped - 8 lines]
> >
> > Any help would be appreciated.
You can try the method described in this blog post:
http://chrissyblanco.blogspot.com/2006/07/infopath-2007-file-attachment-control.html
The translation to VB.NET would look something like the following, where
base64encodedstring is the base64 encoded string for the attachment:
Dim attachmentNodeBytes() As Byte =
Convert.FromBase64String(base64encodedstring)
Dim fnLength As Integer = attachmentNodeBytes(20) * 2
Dim fnBytes() As Byte
ReDim fnBytes(fnLength)
Dim i As Integer
For i = 0 To fnLength
fnBytes(i) = attachmentNodeBytes(24 + i)
Next
Dim charFileName As Char() = UnicodeEncoding.Unicode.GetChars(fnBytes)
Dim fileName As String = New String(charFileName)
fileName = fileName.Substring(0, fileName.Length - 1)
Dim fileContents() As Byte
ReDim fileContents(attachmentNodeBytes.Length - (24 + fnLength))
For i = 0 To fileContents.Length - 2
fileContents(i) = attachmentNodeBytes(24 + fnLength + i)
Next
Dim fs As FileStream = New FileStream("C:\" & fileName, FileMode.Create)
fs.Write(fileContents, 0, fileContents.Length)
fs.Close()
---
S.Y.M. Wong-A-Ton
> Using InfoPath 2007, I would like to write an attached file to my local
> drive using VB.net within the form. As the attachments are encoded as base64,
[quoted text clipped - 5 lines]
>
> Any help would be appreciated.
kb at donovanhill - 19 Nov 2007 05:29 GMT
Your code worked, fanastic job!!
THANKS VERY MUCH!

Signature
kb
> You can try the method described in this blog post:
> http://chrissyblanco.blogspot.com/2006/07/infopath-2007-file-attachment-control.html
[quoted text clipped - 40 lines]
> >
> > Any help would be appreciated.
S.Y.M. Wong-A-Ton - 20 Nov 2007 00:31 GMT
I cannot take credit for the original code; only for the VB.NET translation.
:) I'm glad it worked without much modification, since I don't usually write
much VB code.
---
S.Y.M. Wong-A-Ton
> Your code worked, fanastic job!!
>
[quoted text clipped - 44 lines]
> > >
> > > Any help would be appreciated.