|
Technical Interview Questions
Visual Basic Interview Question
ASP .NET Interview Questions
C++ Interview Questions
C
Interview Questions
.........More
Programming Source Codes
C/C++ Source Codes
C# Source Codes
.........More
Aptitude Interview Questions
C/C++ Aptitude Questions
C Aptitude Questions
.........More
Tutorials
C Tutorial
C++ Tutorial
.........More
Soft Skills
Communication Skills
Leadership Skills
.........More
|
|
C# Source Codes
Listing files in a folder
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace ListFilesInFolder
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.TextBox txtPath;
private System.Windows.Forms.ListBox lstFiles;
private System.Windows.Forms.Button cmdListFilesInFolder;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.txtPath = new System.Windows.Forms.TextBox();
this.lstFiles = new System.Windows.Forms.ListBox();
this.cmdListFilesInFolder = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// txtPath
//
this.txtPath.Location = new System.Drawing.Point(8, 8);
this.txtPath.Name = "txtPath";
this.txtPath.Size = new System.Drawing.Size(272, 20);
this.txtPath.TabIndex = 0;
this.txtPath.Text = "C:\\AI WEBSITES\\www.p2bconsortium.com\\";
//
// lstFiles
//
this.lstFiles.Location = new System.Drawing.Point(8, 64);
this.lstFiles.Name = "lstFiles";
this.lstFiles.Size = new System.Drawing.Size(272, 173);
this.lstFiles.TabIndex = 1;
//
// cmdListFilesInFolder
//
this.cmdListFilesInFolder.Location = new System.Drawing.Point(80, 32);
this.cmdListFilesInFolder.Name = "cmdListFilesInFolder";
this.cmdListFilesInFolder.Size = new System.Drawing.Size(112, 24);
this.cmdListFilesInFolder.TabIndex = 2;
this.cmdListFilesInFolder.Text = "List Files In Folder";
this.cmdListFilesInFolder.Click += new System.EventHandler(this.cmdListFilesInFolder_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.Add(this.cmdListFilesInFolder);
this.Controls.Add(this.lstFiles);
this.Controls.Add(this.txtPath);
this.Name = "Form1";
this.Text = "List Files In Folder";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void cmdListFilesInFolder_Click(object sender, System.EventArgs e)
{
System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(txtPath.Text);
foreach (System.IO.FileInfo f in dir.GetFiles("*.*"))
{
lstFiles.Items.Add(f.Name);
}
}
private void Form1_Load(object sender, System.EventArgs e)
{
}
}
}
<<<----- Return to
C# Source
Code Questions Page.
Have a Question ?
post your questions here. It
will be answered as soon as possible.
Check
Object Oriented Interview
Questions for more Object Oriented Interview Questions with answers
Check
Data Structure
Interview Questions for more data structure interview questions with
answers
|