C# 全站最简单的网盘登录认证;
建议在打开程式认证即可,后续皆可访问;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp6
{
class Program
{
static void Main(string[] args)
{
try
{
Runcmd(@"net use \\172.10.2.6\log /user:test TEST2023");
string server = @"\\172.10.2.6\log\1.txt";
File.WriteAllText(server, "1");
Console.WriteLine("ok");
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
Console.Read();
}
public static void Runcmd(string cmd)
{
ProcessStartInfo startInfo = new ProcessStartInfo("cmd")
{
Verb = "runas",
UseShellExecute = false,
RedirectStandardInput = true,
RedirectStandardOutput = true,
RedirectStandardError = true,
CreateNoWindow = true
};
Process cmdProcess = new Process()
{
StartInfo = startInfo
};
cmdProcess.Start();
cmdProcess.StandardInput.WriteLine(cmd);
cmdProcess.StandardInput.Flush();
cmdProcess.StandardInput.Close();
string output = cmdProcess.StandardOutput.ReadToEnd();
cmdProcess.WaitForExit();
//Console.WriteLine(output);
cmdProcess.Close();
}
}
}
CMD 认证方法:
User: test;
Passwd: TEST2023;
IP Path:\\172.10.2.6\log
用法:"net use \\172.10.2.6\log /user:test TEST2023"
。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
标签:Console,string,c#,网盘,System,2.6,using,cmdProcess,账号密码 From: https://blog.csdn.net/weixin_56830970/article/details/140383554