In Focus
Jabalpur Chapter Meet July 13: Register Now
Chandigarh Chapter: Developers Day on 29 June 2013
Delhi Chapter Hands On June 22: Limited Seats Register Now
Email :
Password :
Remember me?
Forgot password
Contribute
An Article
A Blog
A News
A Video
A Link
An Interview Question
Ask a Question
TECHNOLOGIES
.NET 4.5
Chapters
JavaScript, CSS
SharePoint 2010
Web Development
.NET Assemblies
Coding Best Practices
JQuery
SharePoint 2013
Web Services in C#
ADO.NET in C#
Current Affairs
JSP
Silverlight with C#
Windows 8
AJAX in C#
Databases & DBA
Leadership
Smart Devices
Windows Azure
Android Programming
Design & Architecture
Learn .NET
SQL
Windows Controls C#
Articles C#
Exception Handling C#
LightSwitch 2012
SQL Server 2012
Windows Forms C#
ASP.NET Controls in C#
Expression Studio
LINQ
Testing
Windows Phone 8
ASP.NET MVC with C#
Graphics Design
Mobile & Embedded
TypeScript
Windows Server 2012
ASP.NET Programming
How do I
Office 2013
Visual C#
Windows Store Apps
BizTalk Server
HTML 5
OOP/OOD
Visual Studio .NET
Workflow Foundation in C#
C# Language
Internet & Web
Operating Systems
Visual Studio 2010
WPF
C# Tutorials
iPhone/iPad
PHP
Visual Studio 2012
XAML
C, C++, MFC
Java
Products
WCF with C#
XML
Career Advice
Java and .NET
Project Management
Request a new Category
|
View All
ANSWERS
BLOGS
VIDEOS
INTERVIEWS
BOOKS
LINKS
NEWS
CHAPTERS
CAREER ADVICE
How classes can help in C#.Net ?
SQL Interview Questions
Resource
1
40,000
How to read files in a folder or Directory in C#?
Posted by
Mahesh Chand
in
Resources
on
Jul 06, 2009
Tags:
read files
,
folder
,
directory
,
C#
,
.NET
To read files in a folder or Directory in C#. we writes the code to reads a directory and lists all the files in this directory including the file size and creation date.
Tweet
27649
0
0
This code snippet reads a directory and lists all the files in this directory including the file size and creation date.
using System;
using System.IO;
namespace FileOperationsSample
{
class Program
{
static void Main(string[] args)
{
// Change this path to the directory you want to read
string path = "C:\\Junk";
DirectoryInfo dir = new DirectoryInfo(path);
Console.WriteLine("File Name Size Creation Date and Time");
Console.WriteLine("=================================================================");
foreach (FileInfo flInfo in dir.GetFiles())
{
String name = flInfo.Name;
long size = flInfo.Length;
DateTime creationTime = flInfo.CreationTime;
Console.WriteLine("{0, -30:g} {1,-12:N0} {2} ", name, size, creationTime);
}
Console.ReadLine();
}
}
}
This Feature is Sponsored By
.NET Diagramming framework designed for creating advanced solutions
How to read a text file in C#?
Tags:
read text
,
textfile
,
C#
,
WPF
How to read and write binary data files in C#?
Tags:
bindary data file
,
read
,
write
,
BinaryWriter
,
BinaryReader
,
binary files
Related Resources
How to delete a folder or directory in C#
How to read and write binary data files in C#?
How to rename a directory or folder in C#
Tips and Tricks for C# Windows 8 developer: Read and write roamed application settings
Get logical drives in C#
comments
View Previous Comments
of
COMMENT USING
PREMIUM SPONSORS
Nevron
Nevron Software is a global leader in component based data visualization technology for a diverse range of Microsoft centric platforms. Nevron Data Visualization components are used by many companies, educational and government organizations around the world.
TOP RESOURCES
WPF Button with Image
How to play sound using C#
How to read and write binary data files in C#?
How to use a SaveFileDialog in WPF
Get Started with Windows Azure
How to create a GroupBox in WPF?
Convert String to XML - .NET/C#
How to Close a WPF application programmatically?
How to Style a Tab Control in WPF
How to Add and Remove Items in a WPF ListBox
View All
MOST LIKED RESOURCES
Just Code : Code Analysis and Error Check
SharePoint 2013’s Social Features
Powershell script to bring your publish to the next level
What is SignalR
Follow @twitterapi
HOT KEYWORDS
.NET
.NET Framework
ADO.NET
ASP.NET
Database
Datagrid
Design
games
GridView
jquery
LINQ
SharePoint
SharePoint 2010
Silverlight
Silverlight 5
silverlight tutorial
sql server
Thread
try
tutorials
VB.NET
WCF
Windows Forms
WPF
XML
SPONSORED BY
Download Your Free HTML5/jQuery Grid Now!
Make Your Data Do More with the Ignite UI Grid. Launch eye-popping, performance-driven HTML5 apps w/ Ignite UI's free jQuery Grid.
My Facebook Friends
WHITEPAPERS AND BOOKS
Interview Questions on SharePoint 2013
SharePoint 2010 Administration & Development
Getting Started with Managed Metadata Service in SharePoint 2010
Windows Phone 7 Hileleri
Windows Phone Development Step by Step Tutorial
Essentials of SharePoint 2010: Business Intelligence Capabilities
Working with Directories in C#
FileInfo in C#
Programming List with C#
Source Code: Graphics Programming with GDI+
View All
Poll
Result
All Polls
Speed of C# Corner
How do you find speed of C# Corner when visiting the site?
Very Fast
OK
Slow
Very Slow
How do you find speed of C# Corner when visiting the site?
Options
Votes
%
Very Fast
4
7.14
OK
45
80.36
Slow
4
7.14
Very Slow
3
5.36
Total
56
100%