I have an app with a file uploaded that will allow the user to add
multiple files to a listbox, then will upload all files to the server
in a batch.
To do this i have a Public Shared ArrayList at the top of the page to
store the HTMLInputFile objects in.
The problem is that since it is shared, whenever another user is on
the site at the same time, the threads get corrupted.
Is there another way that i can change this around to make it thread
safe?
I have created a class to take the place of the Public Shared
ArrayList, but cannot put it into Viewstate since it holds
HTMLInputFiles (which is what is stored in the arraylist so that they
can be uploaded in batch).
Any help would be great. I thought i had this thing done until two of
us were testing at the same time and we found this big old error.
code is below:
_____________________________
Public Class UpdateForm
Public Shared InputFile As ArrayList = New ArrayList
Private Sub btnAddFile_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btnAddFile.Click
....
lbFileList.Items.Add(FindFile.PostedFile.FileName)
InputFile.Add(FindFile)
End Sub
Private Sub btnRemove_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btnRemove.Click
InputFile.RemoveAt(lbFileList.SelectedIndex)
lbFileList.Items.Remove(lbFileList.SelectedItem.Text)
End Sub
Private Sub btnSubmit_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btnSubmit.Click
Dim File As System.Web.UI.HtmlControls.HtmlInputFile
For Each File In InputFile
Dim fn As String = System.IO.Path.GetFileName
(File.PostedFile.FileName)
File.PostedFile.SaveAs(ConfigurationSettings.AppSettings
("BASE_PATH") + sStoragePath + "\" + fn)
Response.Flush()
Next
InputFile.Clear()
lbFileList.Items.Clear()
End Sub
End class
------------------------ Yahoo! Groups Sponsor --------------------~-->
Most low income homes are not online. Make a difference this holiday season!
http://us.click.yahoo.com/5UeCyC/BWHMAA/TtwFAA/saFolB/TM
--------------------------------------------------------------------~->
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/