wince c# 创建桌面快捷方式

来源:互联网 发布:网络教育认证 编辑:程序博客网 时间:2024/05/01 20:25

static void Create()
        {
            string PathGPRS = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) + "\\AppCenter.exe";
            string PathGPRSTrue = @"/Windows/Desktop/AppCenter.exe.lnk";

 

            if (!File.Exists(PathGPRSTrue))
            {
                //File.Copy(PathGPRS, PathGPRSTrue, true);
                try
                {

                    string text = (PathGPRS.Length + 2).ToString() + "#\"" + PathGPRS + "\"";
                    byte[] buf = new byte[text.Length];
                    buf = System.Text.Encoding.GetEncoding(936).GetBytes(text.Substring(0, text.Length));
                    FileStream fs = new FileStream(PathGPRSTrue, FileMode.CreateNew);
                    fs.Write(buf, 0, buf.Length);
                    fs.Close();
                    fs = null;

                }
                catch (System.Exception ex)
                {

                }
            }

        }

如上测试正常。

0 0
原创粉丝点击