应该设置它的SelectedItemIndex
System.IO.File fl= new System.IO.File ();

解决方案 »

  1.   

    File不用定义,直接用即可,示例如下:
    using System;
    using System.IO;class Test 
    {
        public static void Main() 
        {
            string path = @"c:\temp\MyTest.txt";
            if (!File.Exists(path)) 
            {
                // Create a file to write to.
                using (StreamWriter sw = File.CreateText(path)) 
                {
                    sw.WriteLine("Hello");
                    sw.WriteLine("And");
                    sw.WriteLine("Welcome");
                }    
            }        // Open the file to read from.
            using (StreamReader sr = File.OpenText(path)) 
            {
                string s = "";
                while ((s = sr.ReadLine()) != null) 
                {
                    Console.WriteLine(s);
                }
            }        try 
            {
                string path2 = path + "temp";
                // Ensure that the target does not exist.
                File.Delete(path2);            // Copy the file.
                File.Copy(path, path2);
                Console.WriteLine("{0} was copied to {1}.", path, path2);            // Delete the newly created file.
                File.Delete(path2);
                Console.WriteLine("{0} was successfully deleted.", path2);
            } 
            catch (Exception e) 
            {
                Console.WriteLine("The process failed: {0}", e.ToString());
            }
        }
    }
      

  2.   

    如果你想实例化使用,换FileInfo
      

  3.   

    第一个
    DropDownList.SelectedIndex = DropDownList.Items.IndexOf(DropDownList.Items.FindByValue(Request.QueryString("传递的值")))
      

  4.   

    1.
    SelectedIndex 已重写。获取或设置 DropDownList 控件中的选定项的索引。 
    SelectedItem(从 ListControl 继承) 获取列表控件中索引最小的选定项。 
    SelectedValue(从 ListControl 继承) 获取列表控件中选定项的值,或选择列表控件中包含指定值的项。 
    你要设置,不是获取,所以只能用SelectedIndex ,先找到对应的内容项的index,再设定SelectIndex
    2.
    是否没有引用System.IO.File
    using System.IO.File;
    如果不是我就不清楚了,可能Framework有问题了。
      

  5.   

    问题1:
    for(int i=0;i<DropDownList1.Items.Count;i++)
    {
    if(DropDownList1.Items[i].Text==Request["type"])
    {
    DropDownList1.SelectedIndex=i;
    }
    }
    DropDownList1.DataBind();
      

  6.   

    1.DropDownList.SelectedItem是只读属性,不能被赋值,
    要用楼上的说的DropDownList.SelectedItem才行
      

  7.   

    写错了,是DropDownList1.SelectedIndex才对
      

  8.   

    該死的﹐原來定義一個變量不行﹐直接用就可以了
    using System.IO;...
    File.Delete...
    //就OK了﹐奇怪怎么在VB.net里卻可以先定義成一個變量