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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T20:39:36+00:00 2026-05-10T20:39:36+00:00

I need to test if a file is a shortcut. I’m still trying to

  • 0

I need to test if a file is a shortcut. I’m still trying to figure out how stuff will be set up, but I might only have it’s path, I might only have the actual contents of the file (as a byte[]) or I might have both.

A few complications include that I it could be in a zip file (in this cases the path will be an internal path)

  • 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. 2026-05-10T20:39:37+00:00Added an answer on May 10, 2026 at 8:39 pm

    Shortcuts can be manipulated using the COM objects in SHELL32.DLL.

    In your Visual Studio project, add a reference to the COM library ‘Microsoft Shell Controls And Automation’ and then use the following:

    /// <summary> /// Returns whether the given path/file is a link /// </summary> /// <param name='shortcutFilename'></param> /// <returns></returns> public static bool IsLink(string shortcutFilename) {     string pathOnly = System.IO.Path.GetDirectoryName(shortcutFilename);     string filenameOnly = System.IO.Path.GetFileName(shortcutFilename);      Shell32.Shell shell = new Shell32.ShellClass();     Shell32.Folder folder = shell.NameSpace(pathOnly);     Shell32.FolderItem folderItem = folder.ParseName(filenameOnly);     if (folderItem != null)     {         return folderItem.IsLink;     }     return false; // not found } 

    You can get the actual target of the link as follows:

        /// <summary>     /// If path/file is a link returns the full pathname of the target,     /// Else return the original pathnameo '' if the file/path can't be found     /// </summary>     /// <param name='shortcutFilename'></param>     /// <returns></returns>     public static string GetShortcutTarget(string shortcutFilename)     {         string pathOnly = System.IO.Path.GetDirectoryName(shortcutFilename);         string filenameOnly = System.IO.Path.GetFileName(shortcutFilename);          Shell32.Shell shell = new Shell32.ShellClass();         Shell32.Folder folder = shell.NameSpace(pathOnly);         Shell32.FolderItem folderItem = folder.ParseName(filenameOnly);         if (folderItem != null)         {             if (folderItem.IsLink)             {                 Shell32.ShellLinkObject link = (Shell32.ShellLinkObject)folderItem.GetLink;                 return link.Path;             }             return shortcutFilename;         }         return '';  // not found     } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a 200 MB text file. But, I need to test my program
I need to read test.TXT file(tab delimited) into MATLAB. TXT file have form: Datum
I need to test Perl Application ( File operation , Data base operation..etc )
I need to find all the occurences of a file Test.TXT in c:\ or
I need to test my application. Its a VoIP but each time I need
I need to test, if an instance is exactly of a given type. But
I have a test file and according to it I need to build my
I have a test file in MSBuild to create a ZIP. I need exclude
I have the following file: test 1 My 2 Hi 3 i need a
I'm trying to use the Thor::Actions template method to generate some C++ test file

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.