Create directory and file upload control

27 Nov

This is a control that first create a physical path and after let you use it as upload to anywhere in the web server for files of any extension.

Important : This was done with this web reference.

Amazing place to learn ASP.NET.  It’s free, but accepts the donations for the continuity of the project.

Sorry the designer part of the code wordpress not permit me to include in the post, after a couple of intents was not possible.

It easy to create.  In 2 minutes you can see it running.


2.add 1 textbox, 1 file upload control, 1 button

3.put the the next code in the file .vb

create_uploadCTRL.ascx.vb (filename)

(code begin)

Imports System.IO

Partial Class create_uploadCTRL

Inherits System.Web.UI.UserControl

Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click


Directory.CreateDirectory(MapPath(“.”) & “\” & txtDir.Text)

Catch ex As Exception

lblStatus.Text = ex.Message

End Try

If myFileUpload.HasFile Then

‘myFileUpload.SaveAs(Server.MapPath(“.”) & “\” & txtDir.Text & myFileUpload.FileName)

myFileUpload.SaveAs(Server.MapPath(“.”) & “\” & txtDir.Text & “\” & myFileUpload.FileName)

End If

End Sub

End Class

(code end)


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: