protected void DownloadFile(object sender, EventArgs e) { RedisDataContext redisContext = new RedisDataContext(); LinkButton value = (LinkButton) sender; string fileName = ""; string ext = ""; int val = value.Text.LastIndexOf("."); if (val >= 0) { fileName = value.Text.Substring(0, val); ext = value.Text.Substring(val, value.Text.Length-val); } Response.ContentType = "application/octet-stream"; Response.AppendHeader("Content-Disposition", "attachment; filename=" + value.Text); RootDirectory directory = (RootDirectory)Session["directory"]; Byte[] buffer; if (virtualPath.Text.Equals("/")) { buffer = redisContext.ReadFile(directory.un + virtualPath.Text + "/" + value.Text); } else { buffer = redisContext.ReadFile(directory.un + virtualPath.Text + "/" + value.Text); } //string fileContents = System.Text.Encoding.Default.GetString(buffer); //Response.Write(fileContents); Response.BinaryWrite(buffer); //Response.Write(directory.un+virtualPath.Text+value.Text); Response.End(); }
public void ItemExistsWhenInsertNewFile() { RedisDataContext dataContext = new RedisDataContext(); dataContext.InsertFile("./anotherFile.txt", "c:\\users\\harageth\\documents\\visual studio 2012\\Projects\\PolyglotDemo\\TesterFile.txt"); Assert.IsNotNull(dataContext.ReadFile("./anotherFile.txt")); }
public void NoValueWhenSearchForRemovedKeyTempTxt() { RedisDataContext dataContext = new RedisDataContext(); dataContext.DeleteFile("harageth./temp.txt"); Assert.IsNull(dataContext.ReadFile("harageth./temp.txt")); }
public void HasValueWhenSearchForKeyTempTxt() { var dataContext = new RedisDataContext(); byte[] val = dataContext.ReadFile("harageth./temp.txt"); Assert.IsNotNull(val); }