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 3434422
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T07:41:48+00:00 2026-05-18T07:41:48+00:00

Sometimes it is weird to encounter File not Found Error in running. But we

  • 0

Sometimes it is weird to encounter File not Found Error in running. But we do not know how to bypass the error. There is a line:

  AHash := THash.Create();
  assign(F,Getcurrentdir+'\data.txt');
  reset(F);//File not Found
  while not EOF(F) do
  ...

This(Error) is not always the case. Sometimes it prompts error, sometimes it works well.
We do not know why and how to fix it.
Thank you very much in advance.

Or is there a function to update current dir before assign the file. Will this work?

data.txt is a resource that is packaged and installed to user’s side and is permanently resided in application.exe dir. While our program is running, will the Getcurrentdir func change the actual current dir that the data.txt is located? it may not be the case.

  • 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-05-18T07:41:48+00:00Added an answer on May 18, 2026 at 7:41 am

    You can check if the file exists using the FileExists(filename) function. Its in sysutils.pas.

    If you think the file not found error is not correct, maybe you don’t have enough rights to use the file. Or maybe the file is not on the location you expect it.

    If you think the file is only sometimes “not found” due to sheer magical reasons beyond human understanding, you can use the following function. But its better to find the real reason why the file is not there when it should be there.

    function TryOpenFile(const AFileName: string; const AMaxTries: Integer; var AFile: File): Boolean;
    var
      tries : Integer;
    begin
      tries := 0;
      Result := false;
      while not Result and (tries<=AMaxTries) do begin
        try
          assign(AFile,AFileName);
          reset(AFile);
          Result := True;
        except 
          on e: EFileNotFoundException do begin
            Inc(tries);
            // Add delay if you wish.
          end;
        end;
      end;
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am not sure which one to use? cell.contentView sometimes give me weird errors
I have a very weird problem: sometimes when I call nHibernate update to an
Sometimes I get Oracle connection problems because I can't figure out which tnsnames.ora file
The LogCat output in eclipse suddenly started weird. It sometimes shows all the output
Hi I'm getting nullpointerexception at rs.next() or rs.getString(1) it is really weird that sometimes
Sometimes when I'm editing page or control the .designer files stop being updated with
Sometimes IE6 will render the text of a <ul> list the same color as
Sometimes I need to quickly extract some arbitrary data from XML files to put
Sometimes I have to work on code that moves the computer clock forward. In
Sometimes a labeled break or continue can make code a lot more readable. OUTERLOOP:

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.