I have a web-based project written in VB.NET. I am creating a text file which needs to be saved to the web server that i am running the project from.
I like the look and ease-of-use of the system.web.ui.htmlcontrols.htmlinputfile item for retrieving the file name that i wish to upload. However, i do not want to have the control visibly seen on the aspx page. The reason for this is because the user does not know that the file is being created, and the file name is dynamically created.
What i would like to know is how i can instantiate the PostedFile property of the htmlinputfile without putting this control on the aspx page.
This may sound like a silly question, but its really confusing me. The code i have is below:
halfdetailsfile = "UpdatedDetails_" & tempdate & "_" & staticMemberID & ".txt"
Write the new details to a text file.
Dim savelocation As String
savelocation = Server.MapPath("UpdatedDetails" & "\" & halfdetailsfile)
Dim htmlfile As New Web.UI.HtmlControls.HtmlInputFile()
htmlfile.Value = halfdetailsfile
Dim blah = htmlfile.PostedFile()
htmlfile.PostedFile.SaveAs(savelocation)
The problem is that even though i have assigned a string to the value property of the htmlinputfile (htmlfile), it will not actually instantiate a postedfile. Therefore, blah returns "nothing". As a result, i receive an error when i try to save the postedfile to the savelocation address.
If someone could please offer me some much needed assistance, and quickly would be extremely helpful, then that would be great.
Thanks very much.
Regards,
Michelle
I like the look and ease-of-use of the system.web.ui.htmlcontrols.htmlinputfile item for retrieving the file name that i wish to upload. However, i do not want to have the control visibly seen on the aspx page. The reason for this is because the user does not know that the file is being created, and the file name is dynamically created.
What i would like to know is how i can instantiate the PostedFile property of the htmlinputfile without putting this control on the aspx page.
This may sound like a silly question, but its really confusing me. The code i have is below:
halfdetailsfile = "UpdatedDetails_" & tempdate & "_" & staticMemberID & ".txt"
Write the new details to a text file.
Dim savelocation As String
savelocation = Server.MapPath("UpdatedDetails" & "\" & halfdetailsfile)
Dim htmlfile As New Web.UI.HtmlControls.HtmlInputFile()
htmlfile.Value = halfdetailsfile
Dim blah = htmlfile.PostedFile()
htmlfile.PostedFile.SaveAs(savelocation)
The problem is that even though i have assigned a string to the value property of the htmlinputfile (htmlfile), it will not actually instantiate a postedfile. Therefore, blah returns "nothing". As a result, i receive an error when i try to save the postedfile to the savelocation address.
If someone could please offer me some much needed assistance, and quickly would be extremely helpful, then that would be great.
Thanks very much.
Regards,
Michelle