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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T11:41:11+00:00 2026-05-31T11:41:11+00:00

My desktop application has to download a file from the internet. The path to

  • 0

My desktop application has to download a file from the internet. The path to the file is known, the file name itself is semi variable, i.e. someone else will be putting new files there, and my application will have to download those.

Now I want to make sure that the URL is safe, and that it will be interpreted correctly. Also, if there’s a ‘#’ in a file name (you never know), I do want it to be encoded. Javascript has two distinct functions for this: encodeURI and encodeURIComponent. The latter also encodes ‘#’ characters, amongst other things.
Of course, I could roll my own, but I figured that there’s bound to be functions ready for that, and I might as well avoid making some old mistake.

I will be downloading the file with a object that uses the WinInet series of API functions (InternetOpen and its ilk).

So I started rummaging around on MSDN, and sure enough, there’s UrlCanonicalize. But there’s also UrlEscape, CreateUri (but that’s not present in the Delphi 2010 units), and finally InternetCreateUrl, which requires me to split up the entire URL. I’d rather concatenate the first portion of the URL with the URLEncoded filename.

Also, they all have tons of different flags, different defaults which have changed over the course of the Windows versions, and I can’t figure out the differences anymore. Does anybody know which one is best for this purpose?

  • 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-31T11:41:13+00:00Added an answer on May 31, 2026 at 11:41 am

    try the TIdURI.PathEncode function (located in the idURI unit) which is part of the Indy library included with delphi.

    {$APPTYPE CONSOLE}
    
    {$R *.res}
    
    uses
      idURI,
      SysUtils;
    
    Var
      FileName : string;
      Encoded  : string;
    begin
      try
       FileName:='File with a Very weird f***name*#%*#%<>[]';
       Encoded:=TIdURI.PathEncode(FileName);
       Writeln(Encoded);
      except
        on E: Exception do
          Writeln(E.ClassName, ': ', E.Message);
      end;
      Readln;
    end.
    

    This will return

    File%20with%20a%20Very%20weird%20f%2A%2A%2Aname%2A%23%25%2A%23%25%3C%3E%5B%5D
    

    Also you can take a look in the TIdURI.URLDecode and TIdURI.URLEncode functions.

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

Sidebar

Related Questions

I have a desktop application that needs to upload/download images to/from service computer over
I've inherited a desktop application which has a custom .NET file chooser that is
We have a dilemma; developing desktop application using Matisse or Jigloo.. Matisse has this
I am from Java Desktop Application background. May I know what is the best
We have a desktop application that has been using MapPoint for displaying data on
I am developing a small desktop application in VB.NET. It has to be formal
I'm a desktop application developer. I'm creating a basic website from which to sell
How to detect if desktop application has been modified? The application communicates with a
I'm working with a webapp that has a link to download an xml file.
We have a desktop application, which has been provided a web UI by hosting

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.