public ActionResult WorkingFolder()
        {
            if (!this.IsSetupState())
            {
                return(this.Redirect("/"));
            }

            WorkingFolderStepModel model = new WorkingFolderStepModel
            {
                Path = ConfigurationManager.AppSettings["Settings.WorkingFolder"]
            };

            return(this.View(model));
        }
        public ActionResult WorkingFolder(WorkingFolderStepModel model)
        {
            if (!this.IsSetupState())
            {
                return(this.Redirect("/"));
            }

            if (!this.ModelState.IsValid)
            {
                return(this.View(model));
            }

            model.Path = model.Path.Trim();

            try
            {
                if (!Directory.Exists(model.Path))
                {
                    Directory.CreateDirectory(model.Path);
                }

                string testPath = Path.Combine(model.Path, "Test");
                string testFile = Path.Combine(testPath, "text.txt");

                Directory.CreateDirectory(testPath);
                System.IO.File.WriteAllText(testFile, "Test text");
                System.IO.File.Delete(testFile);
                Directory.Delete(testPath);
            }
            catch (Exception e)
            {
                this.ModelState.AddModelError("Path", e.Message);
                return(this.View(model));
            }


            Configuration configuration = WebConfigurationManager.OpenWebConfiguration("~");

            configuration.AppSettings.Settings["Settings.WorkingFolder"].Value = model.Path;
            configuration.Save();

            return(this.RedirectToAction("Users"));
        }