Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8816513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:38:20+00:00 2026-06-14T04:38:20+00:00

When doing something like … = myFileInfo.FullName – does it access the drive or

  • 0

When doing something like ... = myFileInfo.FullName – does it access the drive or is it loaded to memory with the creation of myFileInfo?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T04:38:22+00:00Added an answer on June 14, 2026 at 4:38 am

    Yes, they are saved in memory – it’s a snapshot of the file when you created the FileInfo class and first accessed a property. You can call the Refresh method to make sure the properties are up to date.

    You can also use the static members of the File class to read the file info at that point in time, however, this incurs the overhead of a security check each time.

    My evidence for this comes from using ILSpy; we can see that, if we access a property like Length:

        public long Length
        {
            [SecuritySafeCritical]
            get
            {
                if (this._dataInitialised == -1)
                {
                    base.Refresh();
                }
                if (this._dataInitialised != 0)
                {
                    __Error.WinIOError(this._dataInitialised, base.DisplayPath);
                }
                if ((this._data.fileAttributes & 16) != 0)
                {
                    __Error.WinIOError(2, base.DisplayPath);
                }
                return (long)this._data.fileSizeHigh << 32 | ((long)this._data.fileSizeLow & (long)((ulong)-1));
            }
        }
    

    Then, if the internal data has not been initialized, Refresh is called:

    public void Refresh()
    {
        this._dataInitialised = File.FillAttributeInfo(this.FullPath, ref this._data, false, false);
    }
    

    This then populates the data for subsequent checks. So unless you call Refresh again, you’ll get the data from the point in time you first accessed a property.

    The reason for caching this data is inferred from the FileInfo MSDN article:

    If you are going to reuse an object several times, consider using the
    instance method of FileInfo instead of the corresponding static
    methods of the File class, because a security check will not always be
    necessary.

    It obviously caches this data to avoid the expense of a SecurityCheck each time, leaving it up to the user to call Refresh and decide when to pay this cost.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does doing something like this use dynamic memory allocation? template <class T, int _size>
I tried doing something like: cmbMyBox.ListFillRange = E2 But the combobox does not seem
I'm doing something like the following: Validate number of nested attributes . I'm checking
I'm doing something like zgrep somepattern access_log.X.gz But I find that a lot of
I am doing something like this in myproject.myapp.urls : from django.conf.urls.defaults import * urlpatterns
I am talking about doing something like this: LOCK TABLE page WRITE; SELECT *
Usually I was doing something like that (just a example): using (Stream xmlStream =
I am currently doing something like this: myFunc(tracer); function tracer(message:String):void{ trace(message); } function myFunc(callback:Function):void{
I am doing something like: $outputFile = getCurrentDBSnapshot($data); where $data is the resource stream
I am doing something like this- http://www.w3schools.com/html5/tryit.asp?filename=tryhtml5_video_js_prop but I want to replace the buttons

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.