string [] fileEntries = Directory.GetFiles(Server.MapPath("temp"));
            string FileName;
            string logstr = "文件:<br>";
            int j = 0;
            int len = 0;
            string path;
            for(int i=fileEntries.Length-1;i>=0;i--)
            {
                j = fileEntries[i].LastIndexOf("\\");
                len = fileEntries[i].Length ;
                FileName = fileEntries[i].ToString();
                /*逐一写出FILENAME就行了*/
            }
            if(fileEntries.Length >0)
            {
                this.trLogList.InnerHtml = logstr;
            }

解决方案 »

  1.   

    首先,你要using System.IO;编译,报什么错就解决什么.没道理不行D
      

  2.   

    是的 using System.IO;加上了
    错误是:嵌套语句不能是声明或标记语言,行34;
      

  3.   

    加个file field 控件就可以的!
      

  4.   

    php版本
    http://aspxboy.com/private/showthread.asp?postid=113
    C#版本
    private void LoadPhoto()
    {
    string strImageName,strPhotoDir,strPhotoPath;
    if( ddlSexList.SelectedItem.Value.Trim().ToUpper() == "BOY" )
    {
    strPhotoDir = Server.MapPath(".")+@"\photo\boy";
    strPhotoPath = @"photo\boy";
    }
    else
    {
    strPhotoDir = Server.MapPath(".")+@"\photo\girl";
    strPhotoPath = @"photo\girl";
    }

    DirectoryInfo dir = new DirectoryInfo(strPhotoDir);
    foreach(FileSystemInfo fsi in dir.GetFileSystemInfos())
    {
    if(fsi is FileInfo)
    {
    FileInfo fi = (FileInfo)fsi;
    strImageName = fi.Name;
    if((fi.Extension == ".gif")||(fi.Extension == ".jpg"))
    {
    ddlPhoto.Items.Add(new ListItem(strImageName,strPhotoPath + "\\" + strImageName));
    }
    }
    }
    ddlPhoto.SelectedIndex=0;
    imgPhoto.ImageUrl = ddlPhoto.SelectedItem.Value;
    }
      

  5.   

    To:biduan(笔端)
    能否给个例子?