Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Dumb question that I can't resolve..(cuz I'm dumb)

So I have a class with a property called AttachmentPath which is an arraylist. I would like to store the size of the attachment along with the path and if I understand it correctly, the Arraylist collection is one-dimensional.

Can I get some ideas on how to store the size of the attachment and use a getAttachmentSize function to have that returned?

Thanks in advance,

Aaron

  • Leaders
Posted

Why not create a structure and then create an arraylist to hold that structure.

 

Not that I think that this is something over your head, but here is a quick example.

'You can add/remove members as necessary to hold all relevant info
Public Structure AttatchmentInfo
   Dim Path As String, Size As Long

   Public Sub New(ByVal Path As String, ByVal size As Long)
       Me.Path = Path
       Me.Size = size
   End Sub

   Public Sub TestFunction()
       Dim List As New System.Collections.ArrayList

       'Create a list of AttatchmentInfos
       List.Add(New AttatchmentInfo("C:\\Don\\Run", 100))
       List.Add(New AttatchmentInfo("Run\\Don\\Run", 102))

       'Example of how to access info
       '(elements must be cast to AttatchmentInfo)
       MessageBox.Show("Att. 1 Path: " & _
       DirectCast(List(0), AttatchmentInfo).Path)
       MessageBox.Show("Att. 2 Size: " & _
       DirectCast(List(1), AttatchmentInfo).Size.ToString)
   End Sub
End Structure

[sIGPIC]e[/sIGPIC]

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...