Code for Working with Files under a Directory?



Code for Working with Files under a Directory?..

Answer / murty

Suppose that you want to list all BMP files under the
f:\Pictures directory. You can write a code as shown in the
code snippet given in Listing 3:

Listing

DirectoryInfo dir = new DirectoryInfo(@"F:\WINNT");
FileInfo[] bmpfiles = dir.GetFiles("*.bmp);
Console.WriteLine("Total number of bmp files",
bmpfiles.Length);
Foreach( FileInfo f in bmpfiles)
{
Console.WriteLine("Name is : {0}", f.Name);
Console.WriteLine("Length of the file is : {0}",
f.Length);
Console.WriteLine("Creation time is : {0}",
f.CreationTime);
Console.WriteLine("Attributes of the file are : {0}",
f.Attributes.ToString());
}

Is This Answer Correct ?    3 Yes 1 No

Post New Answer

More C Sharp Code Interview Questions

Write a program to count 3Letter, 4Letter and 5Letter words from a file and print the number of 3Letter, 4Letter and 5Letter words. Delimiter is space, tab, hifen. Also we should not consider the line in the file after we encounter # in that line.

0 Answers   Mind Tree,


how to get the table names via c sharp and column names also?

2 Answers   Sify,


Code for Reading and writing from a file in c#?

1 Answers  


Write a program which has a function and that function should take 2 or 3 or any number of strings and it should return the largest common prefix of all those strings. If there is no common prefix it should return an empty string. for eg:- INPUT OUTPUT glo {glory,glorious,glod} gl {glad,glow} {calendar,phone} empty string

2 Answers   Mind Tree,


program to check if a number is "perfect number".

1 Answers   Mind Tree, SoftSol,






Write a program to input an integer and - display the reverse - display the sum of each digit - should include logic that considers the input number as any number of digits long

2 Answers   Mind Tree,


Code for Working with Files under a Directory?

1 Answers  


IS Array list is generic or non generic

1 Answers  


write a Program to copy the string using switch case.

0 Answers   Mind Tree, Wipro,


How to Create a Treeview Menu in ASP.NET with C#?

1 Answers  


program to reverse the order of digits in a given number of any length.

1 Answers   Mind Tree,


Coding for Manipulate XML File Data Using C#?

1 Answers  


Categories
  • ASP.NET Code Interview Questions ASP.NET Code (46)
  • VB.NET Code Interview Questions VB.NET Code (9)
  • C Sharp Code Interview Questions C Sharp Code (51)
  • ADO.NET Code Interview Questions ADO.NET Code (8)