In this web log, I volition show how to upload files to a binder using C# lawmaking. This will assist you to understand the file upload feature in C#.
First, we have to create a WinForm similar in the given prototype.
Here is the lawmaking for FileUpload.Designer.cs file.
- namespace FileUploads
- {
- partialclass FileUpload
- {
-
-
-
- private Organization.ComponentModel.IContainer components = nothing ;
-
-
-
-
-
- protected override void Dispose( bool disposing)
- {
- if (disposing && (components != cipher ))
- {
- components.Dispose();
- }
- base .Dispose(disposing);
- }
-
- #region Windows Form Designer generated lawmaking
-
-
-
-
-
- private void InitializeComponent()
- {
- this .btnFile = new System.Windows.Forms.Button();
- this .dgvFile = new System.Windows.Forms.DataGridView();
- this .fileName = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this .filePath = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this .fileSavePath = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this .btnSave = new Organization.Windows.Forms.Push button();
- this .btnClear = new System.Windows.Forms.Push();
- ((Organization.ComponentModel.ISupportInitialize)(this .dgvFile)).BeginInit();
- this .SuspendLayout();
-
-
-
- this .btnFile.Font = new System.Drawing.Font( "Segoe UI" , 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Signal, (( byte )(0)));
- this .btnFile.Location = new System.Cartoon.Point(289, 3);
- this .btnFile.Proper name = "btnFile" ;
- this .btnFile.Size = new System.Drawing.Size(97, 31);
- this .btnFile.TabIndex = 10;
- this .btnFile.Text = "....Choose File" ;
- this .btnFile.UseVisualStyleBackColor = true ;
- this .btnFile.Click += new System.EventHandler( this .btnFile_Click);
-
-
-
- this .dgvFile.AllowUserToAddRows = false ;
- this .dgvFile.AllowUserToDeleteRows = faux ;
- this .dgvFile.BackgroundColor = Organisation.Cartoon.SystemColors.Control;
- this .dgvFile.ColumnHeadersHeight = 28;
- this .dgvFile.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
- this .dgvFile.Columns.AddRange( new System.Windows.Forms.DataGridViewColumn[] {
- this .fileName,
- this .filePath,
- this .fileSavePath});
- this .dgvFile.Location = new Organization.Drawing.Signal(2, 39);
- this .dgvFile.Name = "dgvFile" ;
- this .dgvFile.ReadOnly = true ;
- this .dgvFile.RowHeadersVisible = false ;
- this .dgvFile.RowHeadersWidth = xxx;
- this .dgvFile.Size = new Organization.Drawing.Size(693, 258);
- this .dgvFile.TabIndex = 1;
-
-
-
- this .fileName.DataPropertyName = "cname" ;
- this .fileName.HeaderText = "Proper name" ;
- this .fileName.Name = "fileName" ;
- this .fileName.ReadOnly = true ;
- this .fileName.Width = 150;
-
-
-
- this .filePath.DataPropertyName = "cpath" ;
- this .filePath.HeaderText = "Path" ;
- this .filePath.Name = "filePath" ;
- this .filePath.ReadOnly = true ;
- this .filePath.Width = 250;
-
-
-
- this .fileSavePath.DataPropertyName = "csaveto" ;
- this .fileSavePath.HeaderText = "Save To" ;
- this .fileSavePath.Name = "fileSavePath" ;
- this .fileSavePath.ReadOnly = true ;
- this .fileSavePath.Width = 300;
-
-
-
- this .btnSave.Font = new Arrangement.Drawing.Font( "Segoe UI Semibold" , 9.75F, System.Drawing.FontStyle.Bold, Organization.Drawing.GraphicsUnit.Point, (( byte )(0)));
- this .btnSave.Location = new System.Drawing.Point(351, 304);
- this .btnSave.Name = "btnSave" ;
- this .btnSave.Size = new System.Drawing.Size(98, 32);
- this .btnSave.TabIndex = 9;
- this .btnSave.Text = "Salvage" ;
- this .btnSave.UseVisualStyleBackColor = true ;
- this .btnSave.Click += new Organization.EventHandler( this .btnSave_Click);
-
-
-
- this .btnClear.Font = new System.Drawing.Font( "Segoe UI Semibold" , ix.75F, System.Drawing.FontStyle.Assuming, System.Drawing.GraphicsUnit.Point, (( byte )(0)));
- this .btnClear.Location = new Organisation.Drawing.Point(247, 304);
- this .btnClear.Name = "btnClear" ;
- this .btnClear.Size = new System.Cartoon.Size(98, 32);
- this .btnClear.TabIndex = 10;
- this .btnClear.Text = "Clear" ;
- this .btnClear.UseVisualStyleBackColor = true ;
- this .btnClear.Click += new System.EventHandler( this .btnClear_Click);
-
-
-
- this .AutoScaleDimensions = new System.Cartoon.SizeF(7F, 17F);
- this .AutoScaleMode = Arrangement.Windows.Forms.AutoScaleMode.Font;
- this .BackColor = System.Drawing.SystemColors.Control;
- this .ClientSize = new Organization.Drawing.Size(697, 345);
- this .Controls.Add together( this .btnFile);
- this .Controls.Add together( this .btnClear);
- this .Controls.Add together( this .btnSave);
- this .Controls.Add( this .dgvFile);
- this .Font = new System.Drawing.Font( "Segoe UI" , 9.75F, System.Cartoon.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, (( 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);
- ((System.ComponentModel.ISupportInitialize)(this .dgvFile)).EndInit();
- this .ResumeLayout( false );
-
- }
-
-
Belum ada Komentar untuk "Upload File to Server C# .net Core Mvc Scan for Virus"
Posting Komentar