bala3569
bala3569

Reputation: 11010

How to get the datetime of a file located inside a folder?

Is it possible to get a datetime of a file which is located inside a folder... the folder structure is like dotnet\build\portalFlexLib.swc

I need to get the datetime of portalFlexLib.swc without giving harcore value..

I have tried like this

            DateTime ftime = File.GetCreationTime(txtBoxInput.Text);

It give only the folder datetime...Any suggestion??

Upvotes: 0

Views: 3438

Answers (2)

SimoneF
SimoneF

Reputation: 432

Maybe you could try with FileInfo class?

Fileinfo myFileInfo = new Fileinfo(@"C:\path\to\file");
DateTime ftime = myFileInfo.CreationTime;  

There's the UTC version too;

Datetime ftime = myFileInfo.CreationTimeUtc;

Upvotes: 4

Saeed Amiri
Saeed Amiri

Reputation: 22555

Yes You can do this by file info.

    var f= new FileInfo(fileName);
    var creationDate = f.CreationTime;

Upvotes: 1

Related Questions