我保存到数据库里是文件上传的路径!怎样把文件读出来!我保存到数据库路径的代码如下!if(txtDoc.PostedFile!=null)
{     
string nam = txtDoc.PostedFile.FileName ;
//取得文件名(抱括路径)里最后一个"."的索引
int i= nam.LastIndexOf(".");
txtDoc.PostedFile.SaveAs(Server.MapPath("\\Downloand\\"+name(txtDoc.PostedFile.FileName))); 
string doc="\\Downloand\\"+name(txtDoc.PostedFile.FileName);
}
我将路径doc保存到数据库中!请问如何读取文件!
请代码示例!谢谢!C#语言!!

解决方案 »

  1.   

    string theurl=doc;
    WebResponse objResponse;
    WebRequest objRequest;
    StreamReader sr;
    string cache;
    cache = null;
    objRequest = HttpWebRequest.Create(theurl);
    objResponse = objRequest.GetResponse();
    sr=new StreamReader(objResponse.GetResponseStream(),System.Text.Encoding.GetEncoding("GB2312"));
    String line;
    line = sr.ReadLine();
    while(line!=null) 
    {
    line = sr.ReadLine();
    cache = cache + line + "\n";
    }
      

  2.   

    string strdocPath;
    strdocPath = "C:\\DocumentDirectory\\" + DocumentName;FileStream objfilestream = new FileStream(strdocPath,FileMode.Open,FileAccess.Read);
    int len = (int)objfilestream.Length;
    Byte[] documentcontents  = new Byte[len];
    objfilestream.Read(documentcontents,0,len);
    objfilestream.Close();Response.BinaryWrite(documentcontents);