Произошла ошибка при загрузке из c: \ temp.rdp - PullRequest
1 голос
/ 04 июля 2011

Я пытаюсь открыть RDP из приложения ASP.NET.я создал метод для создания .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();
    }
}

любая идея будет оценена по достоинству!

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...