你给string FPath = FileUpload1.PostedFile.FileName;处设置个断点,然后F5运行看看
FPath有米有值。

解决方案 »

  1.   

    不执行那就是说FPath为空了,有什么好看的?
      

  2.   

    if (FPath != null) 是""吧?应该不会有null了
      

  3.   

    if (FPath != null)  
    请改成
    if (FPath != null or FPath != "")
    试试 null和“”有些地方可以认为一样,有些地方是不同的值。
      

  4.   

    if (FPath != null)有问题了。
    把这句string FPath = FileUpload1.PostedFile.FileName
    改成 string FPath = FileUpload1.PostedFile.FileName.ToString()试试
      

  5.   

    if (FPath != null or FPath != "") 
    这个也试过了,也是不行,为什么上面的那位老大说FPath没有值呢?
    这个主要是用于编辑的页面,如果他不更改图片的话就不需要重新上传,只修改别的值,如果要上传就一起修改上传的值,所以用if (FPath != null or FPath != "") 来判断是否有值,但是老是自己就跳进里面的判断去了,显示Label1.Text = "提示:文件类型不符"; 
      

  6.   

    改成 string FPath = FileUpload1.PostedFile.FileName.ToString()这个也试过了,也是不行,所以觉得很郁闷,不执行if (FPath != null)  ,不论有没有值都直接跳入里面的判断
      

  7.   

    这个控件的 FileUpload1.PostedFile.FileName属性默认是空字符串。比较一下“”或者string.Empty
      

  8.   

    晕。既然都进去提示那个了。
    那你问题就出在 
    if (FileType == "image/bmp"  ¦ ¦ FileType == "image/gif"  ¦ ¦ FileType == "image/pjpeg") 
    这一句了。
      

  9.   

    if (FPath != null)如果FPath为空的话应该执行以下else语句
    else  
            { 
                Socut.Data.ExecuteNonQuery("update nc_admin_car set nc_number='" + number.Text + "',nc_address='" + address.Text + "',nc_action='" + action.Text + "',nc_time='" + time.Text + "' where id=" + strID); 
                Label1.Text = "提示:修改记录成功!";         
            } 
    不论是if (FPath != null or FPath != "") 他都不执行,感觉就和没有这个判断是一样的,所以说和if (FileType == "image/bmp"  ¦ ¦ FileType == "image/gif"  ¦ ¦ FileType == "image/pjpeg") 这个没有什么关系吧
      

  10.   

    if (FPath != null and FPath != "") 
      

  11.   

    我靠,搞定了,用了if (FPath != null && FPath != "") 就OK了,反而单独用if (FPath != null) 或者 if (FPath != "")却不行,有待研究一下~
      

  12.   

    if(string.IsNullOrEmpty(FPath))
    {
    }
      

  13.   

    为什么不跟断点,看看你认为FPath 应该为null时它里面到底是什么呢??? string.Empty?