Zhlw.com - 中华龙网

站长资讯通告:
搜索: 您的位置中华龙网 > 计算机网络 > 网络编程 > C# > 文章列表

一个Web文件上传的C#源代码

作者:bear  来源:转载  发布时间:2006-4-30 15:11:05
//保存文件的路径,包括文件名
  private string GetSavePath(string FileName)
  {
  string path=Request.PhysicalApplicationPath +"\\#CommCcope.mdb";
    string constr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+db;
   OleDbConnection con=new OleDbConnection (constr);
   
   
   try
   {
    //上传文件
    string SavePath=GetSavePath(FileName);
    fileIcon .PostedFile.SaveAs (SavePath);

    //插入数据库
    
    OleDbCommand com=new OleDbCommand ("Insert into FriendLink(SiteName,DISPLAY,LINK) VALUES('"+txtName.Text +"','"+FileName+"','"+txtLink.Text  +"')",con);
    con.Open ();
    com.ExecuteNonQuery ();
    con.Close ();
    flag =true;
   }
   catch(Exception ex)
   {
   Label1 .Text ="错误:"+ex.Message ;
   }
   finally
   {
    if(con.State !=0)con.Dispose ();
   }
   return flag;
   
  
  }


        用户名: 验证码: 验证码,看不清楚?请点击刷新验证码 (注“”为必填内容。)


文章评论: [ 查看全部 ] 网友评论
关于本站 - 网站帮助 - 广告合作 - 友情连接 - 网站地图