Create folder in subfolder

I want to create a folder in a sub folder. I can create a new folder. But not in a already existing folder. I have radio buttons where you can select a folder where you want to add the new folder.

I have this method:

[HttpPost] [ValidateAntiForgeryToken] public ActionResult CreateDirectory(CreateDirectoryModel model) { try { //string validationError = null; string customerSchema = SfsHelpers.StateHelper.GetSchema(); TemplateLibraryEntry entry = GetTemplateLibraryEntry(model.DesignId, customerSchema); bool CreateFolder = (model.Name != null); string folder = model.Directories[model.SelectedFolderId]; //Create folder in folder var path = Path.Combine(Server.MapPath("~/"), entry.FilePath) + folder + "\\" + model.Name; if (Directory.Exists(path)) { ViewBag.Message = Resources.Entity.DesignTemplate.DirectoryExists; return View(model); } if (ModelState.IsValid) { if (model.Name != null) { if (!Directory.Exists(path)) { DirectoryInfo di = Directory.CreateDirectory(path); } } } } catch (Exception ex) { Logger.Current.LogMessage(LogType.Warning, StateHelper.GetSchema(), LogCategory.Sfs, "Unable to create folder: {0}", ex.ToString()); AddDelayedNotification(Resources.Entity.DesignTemplate.FileCouldNotBeUploaded, Notification.NotificationType.Error); } return RedirectToAction(model.DesignId, "DesignTemplate/File"); }

and this is the view:

<div class="well no-padding"> <div class="bg-color-white"> <div class="form-group"> @Html.LabelFor(model => model.Directories, new { @class = "text-bold control-label col-md-2 col-sm-2" }) <div class="col-lg-6 col-md-8 col-sm-10"> @for (var i = 0; i < Model.Directories.Count; i++) { <div> @Html.RadioButtonFor(model => model.SelectedFolderId, i, new { id = "folder" + i }) <label for="[email protected](i)">@Model.Directories[i]</label> </div> } </div> </div> <div class="col-xs-12"> </div> <div class="form-group"> @Html.LabelFor(model => model.Name, new { @class = "text-bold control-label col-md-2" }) <div class="col-lg-6 col-md-8 col-sm-10 "> @Html.EditorFor(model => model.Name, new { htmlAttributes = new { @class = "form-control" } }) @Html.ValidationMessageFor(model => model.Name) @if (ViewBag.Message != null) { <p style="color:#b94a48;">@ViewBag.Message</p> } </div> </div> </div> </div>

the proble is that: string folder = model.Directories[model.SelectedFolderId];

directories are null. But SelectedFolderId is correct

I added: CreateUploadFileFolders(model, model.DesignId);

with this method:

public void CreateUploadFileFolders(CreateDirectoryModel model, string designId) { string customerSchema = SfsHelpers.StateHelper.GetSchema(); TemplateLibraryEntry entry = GetTemplateLibraryEntry(designId, customerSchema); var path = Path.Combine(Server.MapPath("~/"), entry.FilePath); model.DesignId = designId; model.Directories = new List<string>(); model.Directories.Add("/"); model.Directories.AddRange(Directory.GetDirectories(path, "*", SearchOption.AllDirectories)); for (int i = 1; i < model.Directories.Count; i++) { model.Directories[i] = model.Directories[i].Substring(path.Length).Replace('\\', '/'); } model.Directories.Sort(); }

Category:c# Views:16 Time:2018-12-24
Tags: mvc

Related post

  • Create Folder() Showing "".But Folder are not getting created on Sharepoint 2010-01-23

    i would like to create a folder in Shareopoint 2007 with c#. Using DWS Web Service. Code: dwsFolder.CreateFolder(@"Test_FormLib/myNewFolder"); If I use the program for the first time, i get the message: (No Error) the Second time, i get the message:

  • How to create folder in Sharepoint on specified url using web services? 2010-01-27

    Currently i am using DWS CreateFolder function to create folder on Sharepoint (using C#). But problem i am facing is that: As per CreateFolder Defination: (Def: Creates a subfolder in the document

  • How do I pick the most recently created folder using Foreach loop container in SSIS package? 2011-07-04

    I've got an interesting challenge with SSIS. Using a for-each file enumerator, I need to pick the subfolder which has been most recently created, and then iterate through each of the files. Perhaps an example would explain better. The folders look so

  • about folder under subfolder using 2012-03-06

    i want to delete all the under root folder e:\trichy.root folder contain also sub folder like e:\trichy\chn\20008\20204*.mp3 files. pls help me . always getting an error. Dim rootfolder1 As FileInfo rootfolder1 = txtRootFolder.Text Try If Directory.E

  • How to create an icon for newly created folder 2012-05-02

    Iwwant to give a icon to the newly created folder. When I right click on the folder there is nothing about allocating an icon to the folder. Please advise how to go about it ? --------------Solutions------------- I would suppose that you are talking

  • What is the relationship of folder and subfolder in contacts folders? 2012-02-16

    Question about the relationship of folder and subfolder in contact folders. When I created a subfolder I assumed that it was part of the parent folder, so that I could select the parent and be selecting all of the subfolders and their contacts. Inste

  • Using MkDir statement to create folder on the fly 2012-09-14

    Is there anyway to use the MkDir statement to create a folder on an ad hoc basis? Senerio: I was thinking of having a message or text box that would allow me to type in a location ("Washington" or ?) using the MkDir code behind it. This why when I cl

  • create folder in all sub folders 2012-11-25

    I have a Folder structure like so F:\A\APPLE F:\A\ANT F:\A\AROUND F:\B\BATTLE F:\B\BAT F:\B\BAG I want to create a new folder called CAT in all the level 3 folders, i.e under APPLE, ANT, AROUND, etc. So I end up this F:\A\APPLE\CAT F:\A\ANT\CAT F:\A\

  • creating folder not working 2012-12-08

    creating folder not working, when I right click, and select new, the word empty shows up and it is grayed out. Thank you in advance for any help:-) Cat --------------Solutions------------- First of all in windows 7 there is picture/ music/ video/ doc

  • Can you create folder shortcuts and place them wherever I choose to? 2013-02-18

    I have folder shortcuts on my desktop that point to network locations. Because these folder shortcuts are on my desktop they also show up in the top level of Windows Explorer when I open that program. This makes it very easy to browse to whatever net

  • Win7 keeps recreating the folder and subfolder... 2014-05-17

    Win7 keeps recreating the folder and subfolder and file C:\Users\Terry\My Videos\2011-02-23\My Pictures\desktop.ini. I delete the file and folders but next time I restart computer they reappear. Can you help me permanently delete these folders? See t

  • How to delete a folder or subfolder in Windows 8.1 Mail 2014-10-06

    I accidentally created a folder and need to delete it. There doesn't seem to be a way to do this-only to create folders. --------------Solutions------------- You actually can: Open the mail app Navigate to the folder you've created (the folder name w

  • unable to create folder 'new folder'. File system error 65535 2015-02-16

    I have a 2 GB card that I am putting photos onto. It is showing 1.63gb free of 1.83gb but when I try and add more photos I get the message 'the root of drive E is formatted with FAT file system......' and suggests storing the items in a subfolder. Wh

  • Office 365 API - create folder bug and PUT file "content-length" 2018-12-16

    Creating folder issue Creating new subfolder with the same name as parent folder error Here is my request: PUT {base-url}/Files/getByPath('/Bug/Bug') - fails with 409, "NameAlreadyExists" But, this will work: PUT {base-url}/Files/getByPath('/Bug

  • C# ftp client program create folder issue 2009-05-11

    I am writing a simple FTP client using C#. I did not find any samples which could create folder on FTP server, check whether a folder already exists on FTP server. Any referred simple samples? thanks in advance, George --------------Solutions--------

  • amazon S3 boto - how to create folder? 2009-12-21

    how can i create a folder under a bucket using boto library for amazon s3, i followed the manual, and create keys with contents with permission, metadata etc, but no where in the boto's documentation say how to create folders under bucket, or create

  • Create folder for todays date 2010-05-06

    I have a folder named as 2010. In this I want a folder for each month like "Jan10", "Feb10"....."Dec10" In each month folder I want to create folder for "Todays date" I have create a shortcut for that 2010 folder with Target as C:\WINDOWS\explorer.ex

  • VBA to delete Outlook messages from a user created folder over certain time period 2010-05-26

    I'm looking for a VBA code snippet to delete Outlook messages that are six (6) months or older and sit in a user-created folder. What does that code look like? --------------Solutions------------- Here is a example script Sub DeleteOlderThan6months()

  • Error while creating folder 2010-05-31

    I am trying to create folder like this $destination = "../folder_name/_pcode/../_compile"; mkdir($destination); But this gives error UPDATE What i am doing is, taking ../folder_name/_pcode as input from user and I want to create a folder outside the

  • Create folder in document library using SharePoint workflow 2010-07-21

    I want to create folder inside my document library based on other document library in the root. And I want to run this workflow on new document library creation. So let say I have 4 document library: Help News Doc Archive I want to create folder insi

  • Create folder in Sharepoint 2010-07-30

    I need to create a folder in the root directory of Sharepoint 2007. --------------Solutions------------- SPContext.Current.Site.RootWeb.Folders.Add("MyFolder");

  • NSFileManager creating folder (Cocoa error 513.) 2010-08-09

    I'm trying to create a folder inside the /sounds folder of my app. -(void)productPurchased:(UAProduct*) product { NSLog(@"[StoreFrontDelegate] Purchased: %@ -- %@", product.productIdentifier, product.title); NSFileManager *manager = [NSFileManager de

  • Different colors for folds and subfolds in Vim 2010-10-14

    Is it possible to have different set of colors for folds and subfolds, eg: blue foreground on grey background for fold level 1 (default) black foreground on dark yellow background for fold level 2 etc... (although going further down would seem a bit

  • how to create folder in C# and give her full-control & full-sharing 2010-10-19

    how to create folder in C# and give her full-control & full-sharing ? thank's in advance --------------Solutions------------- Well creating the folder is very easy Directory.CreateDirectory( DIRECTORY ); Setting the directory permissions is a bit

  • Create folder with batch but only if it doesn't already exist 2010-11-12

    Can anybody tell me how to do the following in in a DOS batch script? (*.bat): Create a folder only if it doesn't already exist In more detail, I want to create a folder named VTS on the C:\ drive, but only if that folder doesn't already exist. I don

Copyright (C), All Rights Reserved.

processed in 0.100 (s). 11 q(s)