Click here to Skip to main content
16,013,592 members
Please Sign up or sign in to vote.
1.60/5 (2 votes)
See more:
I would like to use the following code to open file named (tt1233.jpg.lnk) in other words open a shourtcut file

VB
Me.PictureBox1.Image = Image.FromFile( )


when I tried to open it the following error accrue:

out of memory

best regards
Posted
Comments
Sergey Alexandrovich Kryukov 11-Jun-14 17:15pm    
Why? why?!
—SA

You will find a recipe for finding a shortcut (.LNK) target here: http://stackoverflow.com/questions/18249263/how-can-i-find-the-destination-of-a-lnk-file-in-vb-net[^].

However, doing so does not seem to be reasonable.

—SA
 
Share this answer
 
Inside a .Ink file there is (even if it's inside the file: this is a part of the second line of a .Ink file:
▼   ‼   T e s t E x p r e s s i o n . t x t     §   ☼    @    ?kVp⌂?☺§   ♀    §           9   ♦    ▼   ‼   D o c u m e n t o   d i   t e s t o     §   ♫    @   P♥nUp⌂?☺    ?   1SPS?jc(=??◄?? ?O?↑?e   ▲    ▼   *   C : \ U s e r s \ J i m m y \ D e s k t o p \ T e s t E x p r e s s i o n . t x t       ]
).

You have to find the path inside the .Ink file. You can use a Console Application like this one I've written:

VB
Console.WriteLine("Insert file Path")
Dim path As String = Console.ReadLine()
Console.WriteLine("Choose way to display: H for hexadecimal,  A for ASCII")
Dim [option] As String = Console.ReadLine()
If File.Exists(path) Then
    Select Case [option]
        Case "A", "a"
            For Each s As String In File.ReadAllLines(path)
                Console.WriteLine(s)
            Next
            Exit Select
        Case "H", "h"
            For Each b As Byte In File.ReadAllBytes(path)
                Console.WriteLine([String].Format("{X}", b))
            Next
            Exit Select
    End Select
End If
Console.ReadKey()


(I've converted the code from C#to VB. If you have problems, there is the C# equivalent)

C#
Console.WriteLine("Insert file Path");
            string path = Console.ReadLine();
            Console.WriteLine("Choose way to display: H for hexadecimal,  A for ASCII");
            string option = Console.ReadLine();
            if (File.Exists(path))
            {
                switch (option)
                {
                    case "A":
                    case "a":
                        foreach (string s in File.ReadAllLines(path))
                            Console.WriteLine(s);
                        break;
                    case "H":
                    case "h":
                        foreach (byte b in File.ReadAllBytes(path))
                        {
                            Console.WriteLine(String.Format("{X}", b));
                        }
                        break;
                }
            }
            Console.ReadKey();
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 11-Jun-14 17:17pm    
Very, very bad, unreliable recipe (if a solution at all). The legitimate solution is actually very simple.
—SA
thank u it is will done

VB
Dim shell As IWshRuntimeLibrary.WshShell = New IWshRuntimeLibrary.WshShell()
        Dim shortcut As IWshRuntimeLibrary.WshShortcut = CType(shell.CreateShortcut(line), IWshRuntimeLibrary.WshShortcut)
        Me.PictureBox1.Image = Image.FromFile(shortcut.TargetPath)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900