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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T06:21:10+00:00 2026-06-06T06:21:10+00:00

I have to move a file in the system32 folder, I used this code:

  • 0

I have to move a file in the system32 folder, I used this code:

//-----------FUNCTION----------------
function GetWindowsSystemDir(): String;
var
  vlBuff: Array[0..MAX_PATH-1] of Char;
begin
  getSystemDirectory(vlBuff, MAX_PATH);
  Result := vlBuff;
end;
//-----------------------------------

const
  SMyFile = GetWindowsSystemDir+'\intructions.txt'; //error here, line 87
var
  S: TStringList;
begin
  S := TStringList.Create;
  try
    S.Add('intructions');
    S.SaveToFile(SMyFile);
  finally
    S.Free;
  end;
end;

gives me error when compiling:

[DCC Error] Unit1.pas(87): E2026 Constant expression expected

Thanks.

  • 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-06T06:21:12+00:00Added an answer on June 6, 2026 at 6:21 am

    As the compiler error message indicates, it expects a constant expression where you’re initializing the const. But you’re calling a function there, and the compiler won’t evaluate it at compile time.

    Declare a variable instead, and assign it inside the regular begin-end block of your code:

    var
      SMyFile: string;
      S: TStringList;
    begin
      S := TStringList.Create;
      try
        S.Add('intructions');
        SMyFile := GetWindowsSystemDir+'\intructions.txt';
        S.SaveToFile(SMyFile);
      finally
        S.Free;
      end;
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have this script that is meant to move a file from one folder
i have in server big files (50mb) and i need this file move to
I have a file in Rev 123, I move the file to another folder
I have written a code to move a file as follows private void Move_Click(object
Hi all i have written a code to move a file from the original
i have a div and and a looping move function that translates an image
I have code using boost to list directory contents, iterate through each file, and
I'm trying to fix an issue, in my application I have this code try
I have a batch file which moves files from one folder to another. The
I have some code that downloads a file from the internet located here: http://www.amsat.org/amsat/ftp/keps/current/nasa.all

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.