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

Please Help With Error: c:\inetpub\wwwroot\admin\filemanager.aspx.vb(76): Expression is of type 'System.Web.UI.HtmlControls.HtmlInputFile', which is not a collection type.

P: n/a
I converted a C# Upload app to VB.NET and am down to one error and was
hoping someone could help me with te error. I would greatly appreciate
help from anyone.

Here is the error:

c:\inetpub\wwwroot\admin\filemanager.aspx.vb(76): Expression is of
type 'System.Web.UI.HtmlControls.HtmlInputFile', which is not a
collection type.

Here is the code:

Imports System
Imports System.Collections
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Web
Imports System.Web.SessionState
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls
Imports System.Xml
Namespace webchange

Public Class attachme
Inherits System.Web.UI.Page
Protected ListBox1 As System.Web.UI.WebControls.ListBox
Protected AddFile As System.Web.UI.WebControls.Button
Protected RemvFile As System.Web.UI.WebControls.Button
Protected FindFile As System.Web.UI.HtmlControls.HtmlInputFile
Protected Upload As System.Web.UI.HtmlControls.HtmlInputButton
Protected Label1 As System.Web.UI.WebControls.Label
Public files As ArrayList = New ArrayList
Public Shared hif As ArrayList = New ArrayList
Protected Image1 As System.Web.UI.WebControls.Image
Public filesUploaded As Integer = 0

Private Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs)
End Sub

Protected Overloads Overrides Sub OnInit(ByVal e As EventArgs)
InitializeComponent()
MyBase.OnInit(e)
End Sub

Private Sub InitializeComponent()
AddHandler Me.AddFile.Click, AddressOf Me.AddFile_Click
AddHandler Me.RemvFile.Click, AddressOf Me.RemvFile_Click
AddHandler Me.Upload.ServerClick, AddressOf
Me.Upload_ServerClick
AddHandler Me.Load, AddressOf Me.Page_Load
End Sub

Private Sub AddFile_Click(ByVal sender As Object, ByVal e As
System.EventArgs)
If Page.IsPostBack = True Then
hif.Add(FindFile)
ListBox1.Items.Add(FindFile.PostedFile.FileName)
Else
End If
End Sub

Private Sub RemvFile_Click(ByVal sender As Object, ByVal e As
System.EventArgs)
If Not (ListBox1.Items.Count = 0) Then
hif.RemoveAt(ListBox1.SelectedIndex)
ListBox1.Items.Remove(ListBox1.SelectedItem.Text)
End If
End Sub

Public Sub Upload_ServerClick(ByVal sender As Object, ByVal e
As System.EventArgs)
Dim id As String = Request.QueryString("id")
Dim ad As String = Request.QueryString("ad")
Dim folder As String = Request.QueryString("Folder")
Dim baseLocation As String = ""
Dim status As String = ""
If folder = "prod" Then
baseLocation = "C:\" + ad + "_" + id + "\" + ad + "_"
+ id + "\"
End If
If folder = "pim" Then
baseLocation = "C:\" + ad + "_" + id + "\" + ad + "_"
+ id + "_pimfiles\"
End If
If folder = "source" Then
baseLocation = "C:\" + ad + "_" + id + "\" + ad + "_"
+ id + "_source\"
End If
If (ListBox1.Items.Count = 0) AndAlso (filesUploaded = 0)
Then
Label1.Text = "Error - a file name must be specified."
Return
Else
For Each HIF As
System.Web.UI.HtmlControls.HtmlInputFile In HIF
Try
Dim fn As String =
System.IO.Path.GetFileName(HIF.PostedFile.FileName )
HIF.PostedFile.SaveAs(baseLocation + fn)
filesUploaded += 1
status += fn + "<br>"
Catch err As Exception
Label1.Text = "Error saving file " +
baseLocation + "<br>" + err.ToString()
End Try
Next
If filesUploaded = HIF.Count Then
Label1.Text = "These " + filesUploaded + " file(s)
were uploaded:<br>" + status
End If
HIF.Clear()
ListBox1.Items.Clear()
End If
End Sub
End Class
End Namespace
Nov 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hi Sean,

I do not know what your code does, and did not examine it deeper, however
this does definitly not work

For Each HIF As System.Web.UI.HtmlControls.HtmlInputFile In HIF

It can be something as
For Each HIFke As System.Web.UI.HtmlControls.HtmlInputFile In HIF

And than things as
HIFke.PostedFile.SaveAs(baseLocation + fn)

I hope this was it?

Cor
Nov 20 '05 #2

P: n/a

Changing to hifke got rid of the error, but the upload control is not
working now. Ill have to see what else I have done.

Thanks for the help.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.