我想对网站进行HTTP调用.我只需要点击URL,不想上传或下载任何数据.什么是最简单,最快速的方法.
我尝试了下面的代码,但它的速度很慢,在第二次重复请求之后,它只是进入超时时间为59秒而不是恢复:
WebRequest webRequest = WebRequest.Create("http://ussbazesspre004:9002/DREADD?" + fileName);
webRequest.Method = "POST";
webRequest.ContentType = "application/x-www-form-urlencoded";
webRequest.ContentLength = fileName.Length;
Stream os = webRequest.GetRequestStream();
os.Write(buffer, 0, buffer.Length);
os.Close();
Run Code Online (Sandbox Code Playgroud)
使用WebClient更有效率吗?
WebClient web = new WebClient();
web.UploadString(address);
Run Code Online (Sandbox Code Playgroud)
我正在使用.NET ver 3.5
我想用C#编写代码以列出所有有权访问(读/写/完全)服务器上共享文件夹的用户/组。
例如:我有一个共享文件夹\ servername \ MyData。现在,我想列出有权访问此文件夹的用户/组。
我试图用Windows命令从服务器检索文件列表 - "DIR/S/B"输出很大(大约400 MB).现在,当我尝试使用以下方法检索它时,需要花费数小时来处理.有没有更快的方法来做到这一点.
string path = args[0];
var start = DateTime.Now;
System.Diagnostics.ProcessStartInfo procStartInfo =
new System.Diagnostics.ProcessStartInfo("cmd", "/c " + "dir /s/b " + path );
procStartInfo.RedirectStandardOutput = true;
procStartInfo.UseShellExecute = false;
procStartInfo.CreateNoWindow = true;
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo = procStartInfo;
proc.Start();
//string [] result = proc.StandardOutput.ReadToEnd().Split('\n'); ;
StreamWriter writer = new StreamWriter("FileList.lst");
while (proc.StandardOutput.EndOfStream != true)
{
writer.WriteLine(proc.StandardOutput.ReadLine());
writer.Flush();
}
writer.Close();
Run Code Online (Sandbox Code Playgroud)