Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

C# Programming

First file within a directory


Hi...I have a requirement to find the first file within a directory. I know
we can use the GetFiles() method of Directory class, but am a little stuck up
with the syntax.

Can somebody plz let me know who this can be done?

Thanks...

Gaurav wrote:
> Hi...I have a requirement to find the first file within a directory. I know
> we can use the GetFiles() method of Directory class, but am a little stuck up
> with the syntax.

> Can somebody plz let me know who this can be done?

You asked the same question a couple of hours ago and
got two replies.

Why not start from there instead of starting a new thread.

Arne

-----------------------------------------------Reply-----------------------------------------------

"Arne Vajhj" <a@vajhoej.dk> wrote in message

news:466766cb$0$90262$14726298@news.sunsite.dk...

> Gaurav wrote:
>> Hi...I have a requirement to find the first file within a directory. I
>> know we can use the GetFiles() method of Directory class, but am a little
>> stuck up with the syntax.

>> Can somebody plz let me know who this can be done?

> You asked the same question a couple of hours ago and
> got two replies.

> Why not start from there instead of starting a new thread.

Do you want me to step on the OP for you? I can certainly do that. It would
be a pleasure. :)

-----------------------------------------------Reply-----------------------------------------------

That would not be necessary.

Arne

-----------------------------------------------Reply-----------------------------------------------

"Gaurav" <Gau@discussions.microsoft.com> wrote in message

news:46FAD943-347B-4B73-A80E-CEFAFC25E7F7@microsoft.com...

> Hi...I have a requirement to find the first file within a directory. I
> know
> we can use the GetFiles() method of Directory class, but am a little stuck
> up
> with the syntax.

> Can somebody plz let me know who this can be done?

string[] files = Directory.GetFiles(filePath);
Array.Sort(files);

http://samples.gotdotnet.com/quickstart/howto/doc/sort.aspx
http://msdn2.microsoft.com/en-us/library/system.array.sort.aspx

-----------------------------------------------Reply-----------------------------------------------

"Arne Vajhj" <a@vajhoej.dk> wrote in message

news:46676cb7$0$90270$14726298@news.sunsite.dk...

I am at your calling when needed, just call with a top post. :)

-----------------------------------------------Reply-----------------------------------------------
What is meant by "the first file within a directory"?  First in what sense?
The one that happens to be the first entry stored in the directory?  Why is
that useful?  Or do you mean the first after the files are sorted by some
criterion, such as name or age?

-----------------------------------------------Reply-----------------------------------------------
On Jun 7, 9:13 am, "Michael A. Covington"

<l@ai.uga.edu.for.address> wrote:
> What is meant by "the first file within a directory"?  First in what sense?
> The one that happens to be the first entry stored in the directory?  Why is
> that useful?  Or do you mean the first after the files are sorted by some
> criterion, such as name or age?

Does the 'First' file  mean the first file you can see in windows
explorer. As per default setting files are sorted based on FileName.
Clarify what exactly you want to achieve. If it's filename sort order
you can use Array.Sort method as pointed out by Arnold.
Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc