tempf = ((float)(upsize + ex.BytesReceived) / size);
                this.progressBar1.Value= Convert.ToInt32(tempf * 100);在本地转化的时候没有问题,可是放到网络上的时候 就报这个错误 System.OverflowException: 值对于 Int32 太大或太小
我把this.progressBar1.Value= Convert.ToInt32(tempf * 100); 这个里面的换成Convert.ToInt64(tempf * 100); 还是不可以 谁可以帮帮忙 

解决方案 »

  1.   

    ToInt32--》ToInt64
    改为int改为long试下
      

  2.   

    tempf = ((float)((upsize + ex.BytesReceived)*100) / size); 
    this.progressBar1.Value= Convert.ToInt32(tempf); 
      

  3.   

    this.progressBar1.Value这个是INT型 怎么修改都没有用 谁可以帮帮忙 QQ 283553162 谢谢了
      

  4.   

    this.progressBar1.Value= Convert.ToInt32(tempf * 100); 
    ==>
    this.progressBar1.Value= Convert.ToInt64(tempf) * 100; 
    试试
      

  5.   

    this.progressBar1.Value= Convert.ToInt64(tempf) * 100;
    无法将类型“long”隐式转换为“int”。存在一个显式转换(是否缺少强制转换?)
    这个我早试过了 不行的 出现这样的错误
      

  6.   

    tempf = ((float)(upsize + ex.BytesReceived) / size); 
    long x = (long)(tempf * 100);
    this.progressBar1.Value= x > int.MaxValue ? int.MaxValue : x; 
      

  7.   

    tempf = ((float)(upsize + ex.BytesReceived) / size); 
    long x = (long)(tempf * 100);
    this.progressBar1.Value = (int)(x > int.MaxValue ? int.MaxValue : x); 
      

  8.   

    是否超出最大值范围,设置最大值:
    progressBar.Maximum = 100; 
      

  9.   

    值取不到啊                this.label2.Text = String.Format(
                        CultureInfo.InvariantCulture,
                        "正在下载:{0}  [ {1}/{2} ]",
                        fileName,
                        ConvertSize(ex.BytesReceived),
                        ConvertSize(ex.TotalBytesToReceive));                filesize = ex.TotalBytesToReceive;
                    tempf = ((float)(upsize + ex.BytesReceived) / size);
                    long x = (long)(tempf * 100);
                    this.progressBar1.Value = (int)(x > int.MaxValue ? int.MaxValue : x); ; 
                    this.progressBar2.Value = ex.ProgressPercentage;
      

  10.   

    超出progressBar值范围
    MaximumSize 设置大小,该大小是 GetPreferredSize 可以指定的上限
    设置百分比
      

  11.   

    看了楼主的代码,问题是:
    string dirPath = context.Server.MapPath("/AutoUpdater/"); 
    改成:
    string dirPath = context.Server.MapPath("~/AutoUpdater/"); 
    大家都很汗...