Skip to content

Instantly share code, notes, and snippets.

@imba-tjd
Last active March 6, 2023 13:10
Show Gist options
  • Save imba-tjd/8378cf0aba60ff616519a1a048216913 to your computer and use it in GitHub Desktop.
Save imba-tjd/8378cf0aba60ff616519a1a048216913 to your computer and use it in GitHub Desktop.
快速打开我的小米的FTP
// csc mi-ftp-open.cs /o /t:winexe
using System.Net.Sockets;
using System.Threading.Tasks;
using System.Diagnostics;
using System.Runtime.InteropServices;
class Program
{
static readonly string[] IPList = {
"192.168.0.100", "192.168.0.101", "192.168.0.102", "192.168.0.103", "192.168.0.104",
"192.168.0.105", "192.168.0.106", "192.168.0.107", "192.168.0.108", "192.168.0.109",
};
[DllImport("user32")]
static extern void MessageBox(nint hWnd, string text, string caption, uint type);
static void Main()
{
var tasks = new Task[IPList.Length];
for (int i = 0; i < IPList.Length; i++)
tasks[i] = new TcpClient(){ SendTimeout = 200 }.ConnectAsync(IPList[i], 2121);
int ndx = Task.WaitAny(tasks);
if (tasks[ndx].IsFaulted)
MessageBox(0, "Undetected", null, 0);
else
Process.Start("explorer", string.Format("ftp://{0}:2121/download", IPList[ndx]));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment