PC Review


Reply
Thread Tools Rate Thread

DimeAttachment save to disk

 
 
Lee Blue
Guest
Posts: n/a
 
      15th Feb 2006
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


 
Reply With Quote
 
 
 
 
alantolan@users.com
Guest
Posts: n/a
 
      15th Feb 2006

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.

 
Reply With Quote
 
Lee Blue
Guest
Posts: n/a
 
      20th Feb 2006
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.

- Le


 
Reply With Quote
 
AlanT
Guest
Posts: n/a
 
      22nd Feb 2006


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.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DimeAttachment Constructor Samuel Microsoft VB .NET 0 11th Aug 2008 02:58 PM
Save Energy, Save Space in Hard Disk? vbahamondes@mekanoasicom.cl Windows Vista Performance 2 25th Jan 2008 06:58 PM
how to get disk icon on save button of save as dialog like 2000 =?Utf-8?B?UmljaFQ=?= Microsoft Excel Misc 2 9th Mar 2006 08:13 PM
DimeAttachment =?Utf-8?B?RXJ2aW4=?= Microsoft Dot NET Compact Framework 0 16th Mar 2005 10:23 AM
how do i save a document to disk i clicked on the disk icon and i. =?Utf-8?B?SmFtaWU=?= Microsoft Word New Users 1 13th Sep 2004 02:14 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:11 PM.