Пример #1
0
        /// <summary>
        /// Upload a file from disk to the board
        /// </summary>
        /// <param name="filename"></param>
        private void UploadImage(String filename)
        {
            if (!File.Exists(filename))
            {
                generateLog.Add("ERROR: Could not open " + filename);
                generationResult = false;
                ShowResultDialog("The image could not be uploaded.");
            }

            String protocol = GetProtocol();

            FileInfo fileinfo = new FileInfo(filename);

            if (protocol == "http")
            {
                generateLog.Add("\r\nUploading MPFS2 image: " + fileinfo.Length + " bytes");
            }
            else
            {
                generateLog.Add("\r\nUploading MPFS Classic image: " + fileinfo.Length + " bytes");
            }

            // Set up web client and the credentials
            web = new MPFS2WebClient();
            if (Settings.Default.UploadUser.Length > 0)
            {
                web.UseDefaultCredentials = false;
                web.Credentials           = new NetworkCredential(Settings.Default.UploadUser, Settings.Default.UploadPass);
            }

            // Update the status bar display
            myStatusMsg.Text = "Contacting device for upload...";
            myProgress.Style = ProgressBarStyle.Marquee;
            Refresh();

            // Register event handlers and start the upload
            web.UploadProgressChanged += new UploadProgressChangedEventHandler(web_UploadProgressChanged);
            web.UploadFileCompleted   += new UploadFileCompletedEventHandler(web_UploadFileCompleted);
            web.UploadFileAsync(new Uri(
                                    protocol + "://" +
                                    Settings.Default.UploadAddress + "/" +
                                    Settings.Default.UploadPath),
                                filename);
        }
Пример #2
0
        /// <summary>
        /// Upload a file from disk to the board
        /// </summary>
        /// <param name="filename"></param>
        private void UploadImage(String filename)
        {
            if (!File.Exists(filename))
            {
                generateLog.Add("ERROR: Could not open " + filename);
                generationResult = false;
                ShowResultDialog("The image could not be uploaded.");
            }

            String protocol = GetProtocol();

            FileInfo fileinfo = new FileInfo(filename);
            if (protocol == "http")
                generateLog.Add("\r\nUploading MPFS2 image: " + fileinfo.Length + " bytes");
            else
                generateLog.Add("\r\nUploading MPFS Classic image: " + fileinfo.Length + " bytes");

            // Set up web client and the credentials
            web = new MPFS2WebClient();
            if (Settings.Default.UploadUser.Length > 0)
            {
                web.UseDefaultCredentials = false;
                web.Credentials = new NetworkCredential(Settings.Default.UploadUser, Settings.Default.UploadPass);
            }

            // Update the status bar display
            myStatusMsg.Text = "Contacting device for upload...";
            myProgress.Style = ProgressBarStyle.Marquee;
            Refresh();

            // Register event handlers and start the upload
            web.UploadProgressChanged += new UploadProgressChangedEventHandler(web_UploadProgressChanged);
            web.UploadFileCompleted += new UploadFileCompletedEventHandler(web_UploadFileCompleted);
            web.UploadFileAsync(new Uri(
                protocol + "://" +
                Settings.Default.UploadAddress + "/" +
                Settings.Default.UploadPath),
                filename);
        }