472,342 Members | 1,825 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,342 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 2592
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...
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...
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...
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...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...

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.