By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,703 Members | 1,400 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,703 IT Pros & Developers. It's quick & easy.

DimeAttachment save to disk

P: n/a
I've been having difficulty in finding a good example of how to save a
DimeAttachment out to disk in VB.Net. I've got past getting the attachment
into my <WebMethod> from a VB6 Soap Client using the low level API. Now it's
on the server in a Web Service written in VB.NET you'd think it would be
easy to save it out to disk. The DimeAttachment exposes a stream. What I
think I should do is use a Byte array to buffer a write to the file system.
Has anyone done this?

- Lee
Feb 15 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a

You can just read from the Dime stream and write to an open file stream
on disk

e.g.

Public Shared Sub WriteFileStream( _
ByVal fullName As String, _
ByVal instream As Stream _
)

Dim fs As New FileStream(fullName, FileMode.CreateNew)
Dim dataInt As Integer

While True
dataInt = instream.ReadByte()
If (dataInt = -1) Then
Exit While
End If
fs.WriteByte(CType(dataInt, Byte))
End While
fs.Close()

end sub
'fullName' is where you wish to put the file
'instream' is the Dime stream
The casting looks a tad strange I admit but blame the streams

ReadByte() returns an integer
WriteByte() writes a byte.
Also, if you do not have code for getting at the Dime stream, you can
use

Dim soapCon As SoapContext = RequestSoapContext.Current
WriteFileStream(fileName, soapCon.Attachments(0).Stream)
hth,
Alan.

Feb 15 '06 #2

P: n/a
Alan,

Thanks. That worked great. Is there any concerns I should have for using
this technique to upload large files (30mb). Is the stream being buffered
during the upload.

- Lee
Feb 20 '06 #3

P: n/a


I'm afraid that I don't know the answer to that one. We have been using
the above code with files of 2MB +- and it works fine. We don't need
to worry about larger files so it was not tested with anything larger
than about 5 MB.

Alan.

Feb 22 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.