等,(好象CSDN服务器不太稳定,有许多页面打不开啊。)

解决方案 »

  1.   

    asp.net版打不开了,是我的机器的问题???
      

  2.   

    那如果我现在获取到路径了
    想要赋值给FileUpload.PostedFile.FileName
    但报错说是只读的
    怎么把fileupload赋个初始值?
    在线等候解答
      

  3.   

    private   void   Page_Load(object   sender,   System.EventArgs   e)   
      {   
      TextBox   txt=new   TextBox();   
      Button   btn   =   new   Button();   
      btn.Click   +=new   EventHandler(btn_Click);   
      }   
      }   
        
      private   void   btn_Click(object   sender,   EventArgs   e)   
      {   
      
      TextBox   txt=上传文件路径;
      接着写上传语句
       
      }不知道能不能满足你
      

  4.   

    txt.text=上传文件路径; 
      

  5.   

    我用Jmail中的附件功能实现文件上传的(只要知道文件路径和文件名就行了)
      

  6.   

    System.Web.HttpPostedFile HtmlInputFile PostedFile.SaveAs(路径);以下是我控件中的一部分代码,也许对你有用 protected override void OnInit(EventArgs e)
    {
    base.OnInit (e);
    if(this.AutoSave == Boolean.Yes)
    {
    Save();
    } }        public void PreSave()
            {
              HtmlInputFile f= (HtmlInputFile) this.FindControl(UniqueID+"_upFile");
                if (f.PostedFile.ContentLength > 0)
                 {
                    if (!CheckSize(f.PostedFile.ContentLength)) throw new Exception("上传文件不能大于" + this.Maxsize + "KB");
                    string m_filename = f.PostedFile.FileName;
                    m_filename = m_filename.Substring(m_filename.LastIndexOf("\\") + 1);
     this.uploadfilename = m_filename;
                 }
            }
    public void Save()
    {
    if(Page.IsPostBack)
    {

    //HttpContext.Current.Response.Write("sfas"); /*开始处理文件
     * 
     * [检测合法性]
     * 
     * 1.文件大小
     * 2.如果允许上传项不空,则检测是否是允许内的
     *  如果允许上传项为空,则检测是否是不允许上传的
     * 
     * [保存文件]
     * 1.生成保存目录,如果不存在则建立
     * 2.检测文件是否存在,如果存在则+1
     * 3.检测
     * 
     HtmlInputFile f= (HtmlInputFile) this.FindControl(UniqueID+"_upFile");
    if(f.PostedFile.ContentLength >0)
    {
                        //if(!CheckSize(f.PostedFile.ContentLength)) throw new Exception("上传文件不能大于" + this.Maxsize + "KB");
    string m_filename = f.PostedFile.FileName;
    m_filename = m_filename.Substring(m_filename.LastIndexOf("\\")+1);
    this.ext = m_filename.Substring(m_filename.LastIndexOf("."));
    if(!CheckType(this.ext)) 
    {
    throw new Exception("上传文件格式错误!");
    // HttpContext.Current.Response.Write("<script language='javascript'>window.alert('上传文件格式错误!')</script>");

    }
    if ((string.Compare(m_filename,"program.xls", true) == 0)==false){m_filename="program.xls";}



    string temppath = this.GetSavePath();
    this.fullPath = this.GetFileName(m_filename);                    //string m_fullsavePath = HttpContext.Current.Request.PhysicalApplicationPath + "\\" + this.fullPath;
                        string m_fullsavePath = this.fullPath;
    if(this.Uptype == Uptype.File)
    {
    eZip tempZip = new eZip();
    tempZip.Password = this.ZipPassword;
    if(this.Savetype == Savetype.Zip)
    {
    f.PostedFile.SaveAs(m_fullsavePath); tempZip.Level = Convert.ToInt32(this.ZipLevel); tempZip.Zipname = m_fullsavePath+".zip";
    tempZip.CreateZip();
    tempZip.AddFile(m_fullsavePath);
    if(this.AccFile != null) 
    {
    tempZip.AddFile(this.AccFile);
    }
    if(this.AccInfo != null)
    {
    tempZip.AddText("ReadMe.eUpload.Txt",this.AccInfo);
    }
    tempZip.FinishZip();

    //Zip(m_fullsavePath,this.ZipLevel);
    System.IO.File.Delete(m_fullsavePath);
    this.fullPath = this.fullPath + ".zip"; }
    else if(this.Savetype == Savetype.UnZip)
    {
    string _unzipPath;
    if(this.UnZipPath == null)
    {
    _unzipPath = System.IO.Path.GetDirectoryName(m_fullsavePath);
    }
    else
    {
    _unzipPath = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath ,this.UnZipPath);
    }
    f.PostedFile.SaveAs(m_fullsavePath);
    tempZip.Zipname = m_fullsavePath; tempZip.CreateZip(); tempZip.Unzipdir = _unzipPath; tempZip.Unzip(); //unZip(m_fullsavePath,_unzipPath);
    tempZip.FinishZip();
    System.IO.File.Delete(m_fullsavePath);
    this.fullPath = _unzipPath; }
    else
    {
    f.PostedFile.SaveAs(m_fullsavePath);
    } }
    else
    {
    #region 图片事件处理
    //处理水印事件
    if(this.WaterPrint != null) 
    {
    string m_stemp = m_fullsavePath+".temp";
    f.PostedFile.SaveAs(m_stemp);
    Print(m_stemp,m_fullsavePath);
    }
    else
    {
    f.PostedFile.SaveAs(m_fullsavePath);
    }
    //图片压缩事件
    if(this.CompressPic == Boolean.Yes) 
    {

    string tempPath = m_fullsavePath+".temp";
    System.IO.File.Move(m_fullsavePath,tempPath);
    //等等

    CSP(tempPath,m_fullsavePath,true);
    }
    //处理缩略图事件
    if(this.SmallPic == Boolean.Yes) 
    {
    if(this.SPicName == null| this.SPicName == "")
    {
    this.SPicName = "small_" + this.FileName;
    }
    this.sPicFullName = this.GetSavePath() + "\\" + this.SPicName;
    string m_spsavefull = HttpContext.Current.Request.PhysicalApplicationPath + "\\" +this.sPicFullName;
    CSP(m_fullsavePath,m_spsavefull,false); if(this.OnlySmall == Boolean.Yes)
    {
    File.Delete(m_fullsavePath);
    File.Move(m_spsavefull,m_fullsavePath);
    }
    }
    #endregion
    }
    }

    //throw new Exception(HttpContext.Current.Request.PhysicalApplicationPath + "\\" + this.fullPath);
    } }
      

  7.   

    好像有javascritp中的模拟键盘可以搞定,以前搞过,我帮你找下
      

  8.   

    下面只是一段测试程序,LZ可以改成aspx格式的:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title>
    <script language="javascript">
    window.onload=function()
    {
    var WshShell = new ActiveXObject("Wscript.Shell");
    try
    {
     document.getElementById("upfile").focus();
    WshShell.SendKeys("C:\\up\\test.txt");

    catch(e)
    {

    }  
    WshShell.Quit; 
    }
    </script>
    </head><body>
    <input type="file" id="upfile" name="upfile" />
    </body>
    </html>