从 c:\temp.rdp 加载时发生错误
我正在尝试从 ASP.NET 应用程序打开 RDP。 我创建了一种方法来创建带有连接参数的 .rdp 文件,但是当尝试运行此方法时,出现以下错误:
从 c:\temp.rdp 加载时发生错误
这是我的代码:
public static void RdcTest(string server, string domain, string username, string password)
{
string encyptedPassword = "";
//Calling the CryptUnprotectData API to encypt the password,
//Read this link for how to do this:
//http://www.devnewsgroups.net/group/microsoft.public.dotnet.framework/topic21805.aspx
string filename = @"c:\temp.rdp";
if (!File.Exists(filename))
{
using (FileStream fs = File.Create(filename))
using (StreamWriter sw = new StreamWriter(fs))
{
sw.WriteLine("screen mode id:i:2");
sw.WriteLine("desktopwidth:i:1440");
sw.WriteLine("desktopheight:i:900");
sw.WriteLine("full address:s:" + server);
sw.WriteLine("username:s:" + username);
sw.WriteLine("domain:s:" + domain);
sw.WriteLine("password 51:b:" + encyptedPassword);
}
Process rdcProcess = new Process();
string strExE = Environment.ExpandEnvironmentVariables(@"%SystemRoot%\system32\mstsc.exe");
rdcProcess.StartInfo.FileName = strExE;
rdcProcess.StartInfo.Arguments = filename;
rdcProcess.Start();
}
}
任何想法将不胜感激!
I am trying to open RDP from ASP.NET application.
i created a method to create .rdp file with connection parameters but when tried to run this method i got the following error :
An error occur while loading from c:\temp.rdp
Here's my code:
public static void RdcTest(string server, string domain, string username, string password)
{
string encyptedPassword = "";
//Calling the CryptUnprotectData API to encypt the password,
//Read this link for how to do this:
//http://www.devnewsgroups.net/group/microsoft.public.dotnet.framework/topic21805.aspx
string filename = @"c:\temp.rdp";
if (!File.Exists(filename))
{
using (FileStream fs = File.Create(filename))
using (StreamWriter sw = new StreamWriter(fs))
{
sw.WriteLine("screen mode id:i:2");
sw.WriteLine("desktopwidth:i:1440");
sw.WriteLine("desktopheight:i:900");
sw.WriteLine("full address:s:" + server);
sw.WriteLine("username:s:" + username);
sw.WriteLine("domain:s:" + domain);
sw.WriteLine("password 51:b:" + encyptedPassword);
}
Process rdcProcess = new Process();
string strExE = Environment.ExpandEnvironmentVariables(@"%SystemRoot%\system32\mstsc.exe");
rdcProcess.StartInfo.FileName = strExE;
rdcProcess.StartInfo.Arguments = filename;
rdcProcess.Start();
}
}
any idea will be appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论