473,394 Members | 1,750 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

DimeAttachment save to disk

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
3 2132

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
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


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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: danny van elsen | last post by:
hello all, in my application, I want to save the state of a number of classes to disk: what would be the best way to do this? right now, I'm hard coding the fields of the classes, but of course...
2
by: Tim T | last post by:
Hi, Could someone please point to to a tutorial / code for dynamically resizing images on upload, THEN saving to disk on the webserver. I need users to be able to upload images to my server, but...
0
by: Jason Zhou | last post by:
Hi, There is one constructor of DimeAttachment looks like this: DimeAttachment (string id, string type, TupeFormat typeformat, string path). I know that type is related to typeformat, but...
10
by: gsb58 | last post by:
Hi! I haven't worked with streams before. On a form I have: A. cboValues = A combobox with text values where the user can choose a value B. txtText = A textbox where the user can enter...
4
by: Hrvoje Vrbanc | last post by:
I would like to know the most efficient way to copy an image from an Internet URL to the local hard disk by means of using an ASP.NET page. So, I would like to click the button on the ASP.NET...
1
by: Rocco | last post by:
I have a single Excel workbook stored as an OLE object in an Access table. I am trying to figure out how to save this object as an .xls file, open it, modify it, and resave it. I know how I can...
4
by: Dale | last post by:
I am creating GIF images with transparent backgrounds on-the-fly for a web app and rendering them by using System.Drawing.Image.Save(Response.OutputStream, ImageType.GIF). I am confident that...
12
by: Lee | last post by:
I have the following code using System; using System.Windows.Forms; using System.Drawing; using System.Collections; namespace FINN {
3
by: SveinErik | last post by:
Hi, I'm trying to find a method to save bmp, jpg and png files as ico files, 16x16 size. I have managed to convert and save bmp files to icon, but only in 32x32 size. I can't figure out how to save...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.