/
AlexMy
/
MyFirste
Обзор
Документация
Войти
/
AlexMy
/
MyFirste
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
Form1.cs
66 строк
2 KB
AlexMy
update Form1.cs
04 май 2025, 06:07
04 май 2025, 06:07
894573b
Код
Авторство
О чём код?
using IWshRuntimeLibrary; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.Diagnostics; namespace WindowsFormsApp1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { string shortcutPath = @"C:\Users\Public\Desktop\Wondershare UniConverter 15.lnk"; // Измените это на свой короткий путь string targetFolder = GetShortcutTargetFolder(shortcutPath); if (!string.IsNullOrEmpty(targetFolder)) { // Open the folder in Explorer Process.Start("explorer.exe", targetFolder); } else { MessageBox.Show("Could not resolve shortcut target."); } } private string GetShortcutTargetFolder(string shortcutPath) { try { WshShell shell = new WshShell(); IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(shortcutPath); string targetPath = shortcut.TargetPath; // If target is a file, get its directory if (System.IO.File.Exists(targetPath)) { return System.IO.Path.GetDirectoryName(targetPath); } else if (System.IO.Directory.Exists(targetPath)) { return targetPath; } else { // Target does not exist return null; } } catch { return null; } } } }