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

  • SEARCH
  • Home
  • 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 8561921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:36:49+00:00 2026-06-11T16:36:49+00:00

Looking at the System.IO.File class, for example, I see the static Exists method, but

  • 0

Looking at the System.IO.File class, for example, I see the static Exists method, but I don’t see any ExistsAsync counterpart. I suspect File.Exists could block for quite some time if the file in question is, say, on a network share. Sure, I could always use Task.Run, but that won’t make use of I/O completion ports.

I could ask the same about many other static methods of the File class.

  • 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-11T16:36:51+00:00Added an answer on June 11, 2026 at 4:36 pm

    I don’t know why there isn’t a File.ExistsAsync method. It could be that “another process can potentially do something with the file in between the time you call the Exists method and perform another operation on the file, such as Delete” and that catching exceptions is still required to ensure proper function of an application that accesses an existing file.

    In any case, you could write your own.

    public static async Task<bool> FileExistsAsync(string file)
    {
        return await Task.Factory.StartNew(() => File.Exists(file));
    }
    

    …which of course does not use IO Completion to get asynchronous IO…

    Update: I think File is generally a convenience wrapper. You can do almost everything that File offers using other APIs, which do offer asynchronous abilities. In the case of Exists, it doesn’t use anything that could use IO Completion ports, it just calls FindFirstFile and checks for error.

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

Sidebar

Related Questions

I am looking at the File System Filter driver example in the WDK called
I'm looking for a cross platform file system watcher, similar to the FileSystemWatcher class
I'm looking for a way to search a file system that contains approximately 1TB
I have been looking into libraries for a file system that will allow path
I have been looking for a C# tree control for displaying a file system
CompositionContainer.ComposePart is an extension method. why is that? Looking into the System.Componentmodel.Composition assembly, it
Consider the following class in a file MyClass.cs using System; public class MyClass :
I've been looking over the Doom 3 SDK code, specifically their File System implementation.
I'm looking to test system responsiveness etc. on a few machines under certain CPU
I'm looking content management system that would have features similar to stackoverflow: Users can

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.