Use DIME/attatchment to download an application

Discussion in 'ASP .Net' started by =?Utf-8?B?TmlrbGFz?=, Aug 10, 2004.

  1. Hi
    I have no problem downloading an image with Web Services Enhancements and
    the DIME specification, but how do I dowwnload an application?
    Regards
    /Niklas

    Web service:

    <WebMethod()> _
    Public Sub CreateDimedApplication(ByVal FileName As String)
    Dim sendFile As System.IO.FileStream
    sendFile = System.IO.File.OpenRead(FileName)
    Dim att As New DimeAttachment("application/dime", TypeFormat.Unknown,
    sendFile)
    ResponseSoapContext.Current.Attachments.Add(att)
    End Sub

    Client:

    Private Sub SaveFile(ByVal att As System.IO.Stream)
    Dim data() As Byte = ConvertStreamToByteBuffer(att)
    If (System.IO.File.Exists(m_localFile)) Then
    System.IO.File.Delete(m_localFile)
    End If
    Dim outFile As System.IO.FileStream
    outFile = System.IO.File.OpenWrite(m_localFile)
    outFile.Write(data, 0, data.Length)
    outFile.Close()
    End Sub

    Private Function ConvertStreamToByteBuffer(ByVal theStream As
    System.IO.Stream) As Byte()
    If (theStream.Position > 0 And theStream.CanSeek) Then
    theStream.Position = 0
    End If
    Dim oneByte As Integer
    Dim tempStream As New System.IO.MemoryStream
    While (oneByte = theStream.ReadByte() <> -1)
    tempStream.WriteByte(CByte(oneByte))
    End While

    Return tempStream.ToArray()
    End Function

    Private Sub cmdCopyFile_Click(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles cmdCopyFile.Click
    Dim svc As MyDimeServiceWse = New MyDimeServiceWse
    svc.CreateDimedApplication(m_serverFile)
    If svc.ResponseSoapContext.Attachments.Count = 1 Then
    SaveFile(svc.ResponseSoapContext.Attachments(0).Stream)
    End If
    End Sub
     
    =?Utf-8?B?TmlrbGFz?=, Aug 10, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ipsita
    Replies:
    1
    Views:
    426
    Sahil Malik
    Oct 26, 2004
  2. UnglueD
    Replies:
    0
    Views:
    383
    UnglueD
    Oct 4, 2006
  3. Martin
    Replies:
    6
    Views:
    537
    Patrice
    Aug 3, 2007
  4. Niklas

    Use DIME/attatchment to download an application

    Niklas, Aug 10, 2004, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    99
    Niklas
    Aug 10, 2004
  5. Replies:
    0
    Views:
    309
Loading...

Share This Page