Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / General MS InfoPath Questions / November 2007

Tip: Looking for answers? Try searching our database.

Writing InfoPath attachments to disk?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
kb at donovanhill - 13 Nov 2007 07:08 GMT
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,
has anyone decoded and removed the header info using VB.net?

One example I have seen uses C#
http://www.cubido.at/Blog/tabid/176/EntryID/40/Default.aspx
I cannot get this to work.

Any help would be appreciated.

Signature

kb

Clay Fox - 13 Nov 2007 20:21 GMT
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.
S.Y.M. Wong-A-Ton - 16 Nov 2007 09:13 GMT
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.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.