Html Open Directory Window to Upload a File
Introduction
In this article, yous'll understand how to upload files to the folder using the c# lawmaking. and step past footstep we'll create a Microsoft ASP.Net file (WebForm1.aspx) and its related code-behind file (WebForm1.aspx.cs) to file uploads.
Create an ASP.Cyberspace application
Allow'southward go to Visual Studio, follow these steps to create a new application to upload files using c#:
- Open Visual Studio.
- Select File carte, point to New then click on Projection.
- In the New Project dialog box, click Visual C# Projects under Projection Types, and so click ASP.Cyberspace Web Awarding under Templates.
In the dialog Location box, type the URL to create the project. For this example, type
http://localhost/FileUpload, which creates the default project proper noun of FileUpload. Observe that the FileUpload.aspx file loads in the Designer view of Visual Studio .NET.
First, nosotros have to create a WinForm similar in the given code. Hither is the code for FileUpload.Designer.cs file.
namespace FileUploads { partial form FileUpload { /// <summary> /// Required designer variable. /// </summary> individual System.ComponentModel.IContainer components = null; /// <summary> /// Make clean upwards whatever resources existence used. /// </summary> /// <param name="disposing">true if managed resource should be disposed; otherwise, false.</param> protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows Course Designer generated code /// <summary> /// Required method for Designer support - practise non modify /// the contents of this method with the code editor. /// </summary> individual void InitializeComponent() { this.btnFile = new Organization.Windows.Forms.Push button(); this.dgvFile = new Organisation.Windows.Forms.DataGridView(); this.fileName = new Organization.Windows.Forms.DataGridViewTextBoxColumn(); this.filePath = new Arrangement.Windows.Forms.DataGridViewTextBoxColumn(); this.fileSavePath = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.btnSave = new System.Windows.Forms.Push button(); this.btnClear = new Arrangement.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.dgvFile)).BeginInit(); this.SuspendLayout(); // // btnFile // this.btnFile.Font = new System.Drawing.Font("Segoe UI", nine.75F, System.Drawing.FontStyle.Regular, System.Cartoon.GraphicsUnit.Betoken, ((byte)(0))); this.btnFile.Location = new System.Drawing.Bespeak(289, iii); this.btnFile.Name = "btnFile"; this.btnFile.Size = new System.Drawing.Size(97, 31); this.btnFile.TabIndex = ten; this.btnFile.Text = "....Choose File"; this.btnFile.UseVisualStyleBackColor = truthful; this.btnFile.Click += new System.EventHandler(this.btnFile_Click); // // dgvFile // this.dgvFile.AllowUserToAddRows = false; this.dgvFile.AllowUserToDeleteRows = false; this.dgvFile.BackgroundColor = Arrangement.Drawing.SystemColors.Command; this.dgvFile.ColumnHeadersHeight = 28; this.dgvFile.ColumnHeadersHeightSizeMode = Organisation.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; this.dgvFile.Columns.AddRange(new Organization.Windows.Forms.DataGridViewColumn[] { this.fileName, this.filePath, this.fileSavePath}); this.dgvFile.Location = new System.Drawing.Point(two, 39); this.dgvFile.Proper noun = "dgvFile"; this.dgvFile.ReadOnly = true; this.dgvFile.RowHeadersVisible = false; this.dgvFile.RowHeadersWidth = xxx; this.dgvFile.Size = new System.Drawing.Size(693, 258); this.dgvFile.TabIndex = 1; // // fileName // this.fileName.DataPropertyName = "cname"; this.fileName.HeaderText = "Name"; this.fileName.Name = "fileName"; this.fileName.ReadOnly = truthful; this.fileName.Width = 150; // // filePath // this.filePath.DataPropertyName = "cpath"; this.filePath.HeaderText = "Path"; this.filePath.Name = "filePath"; this.filePath.ReadOnly = true; this.filePath.Width = 250; // // fileSavePath // this.fileSavePath.DataPropertyName = "csaveto"; this.fileSavePath.HeaderText = "Save To"; this.fileSavePath.Proper name = "fileSavePath"; this.fileSavePath.ReadOnly = true; this.fileSavePath.Width = 300; // // btnSave // this.btnSave.Font = new Arrangement.Drawing.Font("Segoe UI Semibold", nine.75F, System.Drawing.FontStyle.Bold, Arrangement.Cartoon.GraphicsUnit.Betoken, ((byte)(0))); this.btnSave.Location = new System.Cartoon.Betoken(351, 304); this.btnSave.Name = "btnSave"; this.btnSave.Size = new System.Drawing.Size(98, 32); this.btnSave.TabIndex = 9; this.btnSave.Text = "Save"; this.btnSave.UseVisualStyleBackColor = true; this.btnSave.Click += new System.EventHandler(this.btnSave_Click); // // btnClear // this.btnClear.Font = new System.Drawing.Font("Segoe UI Semibold", 9.75F, System.Drawing.FontStyle.Bold, Arrangement.Cartoon.GraphicsUnit.Point, ((byte)(0))); this.btnClear.Location = new System.Drawing.Point(247, 304); this.btnClear.Proper noun = "btnClear"; this.btnClear.Size = new Organisation.Drawing.Size(98, 32); this.btnClear.TabIndex = 10; this.btnClear.Text = "Clear"; this.btnClear.UseVisualStyleBackColor = true; this.btnClear.Click += new Organization.EventHandler(this.btnClear_Click); // // FileUpload // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = Organization.Drawing.SystemColors.Command; this.ClientSize = new System.Drawing.Size(697, 345); this.Controls.Add(this.btnFile); this.Controls.Add(this.btnClear); this.Controls.Add(this.btnSave); this.Controls.Add(this.dgvFile); this.Font = new System.Drawing.Font("Segoe UI", ix.75F, Arrangement.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Signal, ((byte)(0))); this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.MaximizeBox = false; this.Name = "FileUpload"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "File Upload"; this.Load += new System.EventHandler(this.FileUpload_Load); ((Organization.ComponentModel.ISupportInitialize)(this.dgvFile)).EndInit(); this.ResumeLayout(false); }
0 Response to "Html Open Directory Window to Upload a File"
Publicar un comentario