File Properties using C#

File Name of your file:

When reviewing or opening a file, to get its name, the FileInfo class is equipped with the Name property. Here is an sample code:

FileInfo oFileInfo = new FileInfo(strFilename);
MessageBox.Show("My File's Name: \"" + oFileInfo.Name + "\"");

Date and Time a File Created

The Operating System takes care to keep track of the date and time of a file was created. To find out what those date and time values are, you can access the File System Information property using.

DateTime dtCreationTime = oFileInfo.CreationTime;
MessageBox.Show("Date and Time File Created: " + dtCreationTime.ToString());

Find your file extension:

When you access a file or when the user opens one, to know the extension of the file, you can access the value of the FileSystemInfo.Extension property.

MessageBox.Show("myFile Extension: " + oFileInfo.Extension);

Find file size using C#:

One of the routine operations the operating system performs consistly for all the file is calculating the size of files it holds.

MessageBox.Show("myFile total Size: " + oFileInfo.Length.ToString());



Neo said…

Is there any way to determine the file size before content upload?

Or is it possible to extract meta data alone before upload.
RockPSP said…
use FileInfo.Length for size

Popular posts from this blog

ASP.NET website "Cannot read configuration file due to insufficient permissions" in IIS 7 and Windows Server 2008

Error occurred in deployment step 'Install app for SharePoint': The System Account cannot perform this action.

None of the selected features can be installed or upgraded. Setup cannot proceed since no