473,379 Members | 1,355 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,379 software developers and data experts.

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.

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

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

Similar topics

1
by: owyn | last post by:
One of my team memebers wants to pass a VB Collection to use as a pick list for a drop down box on an aspx page. I have to use C# for the code behind for the aspx page. I can not find a collection...
1
by: owyn | last post by:
One of my team memebers wants to pass a VB Collection to use as a pick list for a drop down box on an aspx page. I have to use C# for the code behind for the aspx page. I can not find a collection...
1
by: owyn | last post by:
One of my team memebers wants to pass a VB Collection to use as a pick list for a drop down box on an aspx page. I have to use C# for the code behind for the aspx page. I can not find a collection...
8
by: andyjgw | last post by:
Hi all, hope someone can help here, I'm really stuck. Reading and googling like mad, to no avail so far... Basically, my problem *seems* to boil down to type conversion: Here's a sample web...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.