在PictureBox1.Image中打开shourtcut文件 [英] open shourtcut file in PictureBox1.Image

查看:130
本文介绍了在PictureBox1.Image中打开shourtcut文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用以下代码打开名为(tt1233.jpg.lnk)的文件,换句话说打开一个shourtcut文件



  .PictureBox1.Image = Image.FromFile()





当我试图打开它时会产生以下错误:



内存不足



最佳问候

解决方案

你会在这里找到一个寻找快捷方式(.LNK)目标的方法: http://stackoverflow.com/questions/18249263/how-can-i-find-the-destination- of-ank-file-in-vb-net [ ^ ]。



然而,这样做似乎不合理。



-SA


在.Ink文件中有(即使它在文件中:这是.Ink文件的第二行的一部分:

▼!T e s t E x p r s s i o n。 t xt§☼@?kVp⌂?§§§§9♦▼!D c♫♫♫@ P♥nUp⌂?☺? 1SPS?jc(= ??◄???O?↑?e▲▼* C:\ U sers \ J immy \ D esktop \ T est E xpression.txt] 

)。



您必须在.Ink文件中找到路径。您可以使用我编写的控制台应用程序:



 Console.WriteLine( 插入文件路径
Dim 路径 As String = Console.ReadLine()
Console.WriteLine( 选择显示方式:H表示十六进制,A表示ASCII
Dim [选项] 作为 字符串 = Console.ReadLine()
如果 File.Exists(路径)那么
< span class =code-keyword>选择 案例 [选项]
案例 a
对于 每个 s 作为 字符串 File.ReadAllLines(路径)
Console.WriteLine(s)
下一步
退出 选择
案例 H h
每个 b 作为 字节 File.ReadAllBytes(path)
Console.WriteL ine([ String ]。格式( {X} ,b))
下一步
退出 选择
结束 选择
结束 如果
Console.ReadKey()





(我已将代码从C#转换为VB。如果你有问题,有C#等价物)



 Console.WriteLine(  插入文件路径); 
string path = Console.ReadLine();
Console.WriteLine( 选择显示方式:H表示十六进制,A表示ASCII );
string option = Console.ReadLine();
if (File.Exists(path))
{
switch (选项)
{
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();


谢谢你它会完成



  Dim  shell  As  IWshRuntimeLibrary .WshShell =  IWshRuntimeLibrary.WshShell()
Dim 快捷方式作为 IWshRuntimeLibrary.WshShortcut = CType (shell.CreateShortcut(line),IWshRuntimeLibrary.WshShortcut)
.PictureBox1.Image = Image.FromFile(shortcut.TargetPath)


I would like to use the following code to open file named (tt1233.jpg.lnk) in other words open a shourtcut file

Me.PictureBox1.Image = Image.FromFile( )



when I tried to open it the following error accrue:

out of memory

best regards

解决方案

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


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:

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)

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();


thank u it is will done

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)


这篇关于在PictureBox1.Image中打开shourtcut文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆