移植winform应用程序以在树莓PI上运行

时间:2016-04-20 21:30:19

标签: c# winforms iot windows-10-iot-core raspberry-pi3

我有一个c#winform应用程序,我希望移植到我的新Raspberry PI 3上运行。我处于呻吟模式,因为我认为我的应用程序只会运行。事实并非如此。我的winform应用程序使用夸脱。 net,aforge库和常见的.net库,例如system.configuration。 我虽然我会从我的日志类开始,因为有人提到非UI代码应该很容易转换,如果有任何需要改变的话。 这看起来我将不得不重新发明轮子。具体到startes有一个看看下面的功能。使用system.configuration的任何代码都不起作用。 有没有更简单的方法让我的应用程序工作或我必须逐字转换几乎所有的代码。是否aforge库甚至可以在PI上工作? quart.net会上班吗? 现在我觉得放弃并购买一台运行良好的小型Windows PC"窗户。

C#Winform代码

class Logging
{

    public void Write_To_Log_File(String Message, String Procedure, String Error_Code, String Error_String)
    {
        try
        {
            // If the log file is bigger than allowed size then archive
            if (File.Exists(@ConfigurationManager.AppSettings["LogSavePath"]))
            {

                FileInfo file = new FileInfo(@ConfigurationManager.AppSettings["LogSavePath"]);
                if (file.Length > Convert.ToInt32(ConfigurationManager.AppSettings["FileLogSizeLimit"]))
                {
                    // Rename the file
                    File.Move(@ConfigurationManager.AppSettings["LogSavePath"], @ConfigurationManager.AppSettings["LogSavePath"] + string.Format("{0:yyyy-MM-dd_hh-mm-ss-tt}", DateTime.Now) + ".csv");
                }

            }
            // If log file does not exist then create it and add the headers
            if (File.Exists(@ConfigurationManager.AppSettings["LogSavePath"]))
            {
            }
            else
            {
                // Create the file
                System.IO.File.Create("LogSavePath");
                // Add data
                string[] Headers = { "Time" + "," + "_Message" + "," + "Procedure" + "," + "Error_Code" + "," + "Error_String" };
                System.IO.File.AppendAllLines(@ConfigurationManager.AppSettings["LogSavePath"], Headers);
            }
            if (File.Exists(@ConfigurationManager.AppSettings["LogSavePath"]))
            {
                string[] Log = { DateTime.Now.ToString() + "," + Message + "," + Procedure + "," + Error_Code + "," + Error_String };
                System.IO.File.AppendAllLines(@ConfigurationManager.AppSettings["LogSavePath"], Log);
            }

        }
        catch
        {

        }
    }
}

1 个答案:

答案 0 :(得分:2)

Microsoft为此目的推出了Windows 10 IoT核心移植工具。这可以帮助您从Win32应用程序和库迁移到Windows 10 IoT核心应用程序。更多详情:https://developer.microsoft.com/en-us/windows/iot/win10/tools/iotapiportingtool

相关问题