From the course: C# and .NET Essential Training

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Inspecting file information

Inspecting file information - C# Tutorial

From the course: C# and .NET Essential Training

Inspecting file information

- [Instructor] In addition to working with the contents of files, it is also usually necessary to get information about the files themselves. And this includes basic information such as the size of the file, and when it was created, when it was last updated, what the name of the file is, and so on. Now there are a few different ways to do this, so let's open the program code in the Fileinfo folder and try a few of these out. Now I already have some code to make sure that the example file exists before we try to operate on it. So, first, we can use the functions that are provided directly on the file class itself. So, for example, we can use the File.GetCreationTime function on our filename. And let's make a copy of that line. We can also use the GetLastWriteTime, and let's also call GetLastAccessTime. We can also set file attributes. So, for example, whether a file is hidden or read-only, and we can do that by calling…

Contents