none
Cursor.Wait 的问题。 RRS feed

  • 问题

  • using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Shapes;
    using System.Net;
    using System.IO;
    using Microsoft.Win32;

    namespace FtpClient
    {
        /// <summary>
        /// Window1.xaml 的交互逻辑
        /// </summary>
        public partial class Window1 : Window
        {
            public Window1()
            {
                InitializeComponent();
            }

            private void Window_Loaded(object sender, RoutedEventArgs e)
            {

            }
            private string serverDirectory;
            private void FillDirectoryList(Stream stream)
            {
                StreamReader reader = new StreamReader(stream);
                string content = reader.ReadToEnd();
                string[] files = content.Split('\n');
                listFiles.DataContext = files;
                reader.Close();
            }

            private void buttonOpen_Click(object sender, RoutedEventArgs e)
            {
                Cursor currentCursor = this.Cursor;
                FtpWebResponse response = null;
                Stream stream = null;
                try
                {
                    this.Cursor = Cursor.Wait;

                    //Create the FtpWebRequest object.
                    FtpWebRequest request = (FtpWebRequest)WebRequest.Create(textServer.Text);
                    request.Credentials = new NetworkCredential(textUserName.Text, passwordBox.Password);
                    request.Method = WebRequestMethods.Ftp.ListDirectory;

                    //Send the request to the server.
                    response = (FtpWebResponse)request.GetResponse();

                    //Read the response and fill the list box.
                    stream = response.GetResponseStream();
                    FillDirectoryList(stream);

                    serverDirectory = null;
                    buttonOpenDirectory.IsEnabled = false;
                    buttonGetFile.IsEnabled = false;
                }
                catch (WebException ex)
                {
                    MessageBox.Show(ex.Message, "Error Ftp Client", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                catch (IOException ex)
                {
                    MessageBox.Show(ex.Message, "Error FTP Client", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                finally
                {
                    if (response != null)
                        response.Close();
                    if (stream != null)
                        stream.Close();
                    this.Cursor = currentCursor;
                }
            }
        }
    }
    产生了错误 1 “System.Windows.Input.Cursor”不包含“Wait”的定义,并且找不到可接受类型为“System.Windows.Input.Cursor”的第一个参数的扩展方法“Wait”(是否缺少 using 指令或程序集引用?) C:\BegVCSharp\Chapter32\FtpClient\FtpClient\Window1.xaml.cs 50 38 FtpClient

    问题出在哪里了,Cursor应该是有Wait属性的吧。

    2011年11月17日 13:09

答案

全部回复