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 NoValueWhenSearchForRemovedKeyTempTxt()
        {
            RedisDataContext dataContext = new RedisDataContext();

            dataContext.DeleteFile("harageth./temp.txt");
            Assert.IsNull(dataContext.ReadFile("harageth./temp.txt"));
        }
        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 HasValueWhenSearchForKeyTempTxt()
        {
            var dataContext = new RedisDataContext();

            byte[] val = dataContext.ReadFile("harageth./temp.txt");
            Assert.IsNotNull(val);
        }
        public void FileContainsDataAfterInsertNewFile()
        {
            RedisDataContext dataContext = new RedisDataContext();

            string value = dataContext.InsertFile("./anotherFile.txt", "c:\\users\\harageth\\documents\\visual studio 2012\\Projects\\PolyglotDemo\\TesterFile.txt");
            Assert.AreEqual<string>("This is a specific file that I am adding to the project to make sure that I can add all sorts of files directly to the database.",
                value);
        }
        protected void UploadFile_Click(object sender, EventArgs e)
        {
            if (uploadFileToDatabase.HasFile)
            {

                string contentType = uploadFileToDatabase.PostedFile.ContentType;

                string fileName = uploadFileToDatabase.PostedFile.FileName;

                byte[] byteArray = uploadFileToDatabase.FileBytes;

                MongoDataContext mongoContext = new MongoDataContext();

                RedisDataContext redisContext = new RedisDataContext();
                RootDirectory directory = (RootDirectory) Session["directory"];

                if (directory.files == null)
                {
                    directory.files = new List<string>();
                }

                string virPath = virtualPath.Text;
                if (virPath.Split('/')[1].Equals(""))
                {
                    //virPath;
                }
                else
                {
                    virPath = virPath + "/";
                }

                if (directory.AddFileToCWD(fileName, virPath))
                {
                    mongoContext.UpdateFileStructure(directory);

                    redisContext.InsertFile(directory.un + virPath + fileName, byteArray);
                    /*if (virtualPath.Text.Equals("/"))
                    {

                    }
                    else
                    {
                        redisContext.InsertFile(directory.un + virtualPath.Text + "/" + fileName, byteArray);
                    }*/
                    //Response.Redirect("Default.aspx");
                }
                else
                {
                    Response.Write("Upload failed due to file already existing... in path");//should probably check redis as well...
                }
            }
        }