Creation of folders dynamically in asp.net MVC 4 - c#

I have a application in which I have to create folders dynamically on the server.The functionality is this that user click on the folder icon for creating the folder,after that give name to the folder and upload file in it.It is same like we do on "dropbox.com".
So,anybody suggest if there is any kind of example on the internet or any kind of API that is helpful for me. I have search a lot for this but couldn't succeed.
Thanks in advance

from your controller:
var path = Server.MapPath("~/Directories/YourDirectory");
Directory.CreateDirectory(path);

Related

Tree View Explorer for Sharepoint online folder or Azure Blob

Greetings of the day. I hope everyone is safe and keeping up well.
I need some guidance and any help is highly appreciated.
Current Scenario
I have a tree view folder explorer GUI, when it opens, it shows a Tree View of a folder (the root folder is a Network share) and it's subfolder on Columns 1. User can expand and collapse it by clicking on +/- icons. When user select a folder, then it's contents, mainly files are showed in Column B, and user can tick them, and add them is Column 3 to download all of them on their laptop.
This all coding is written in C#.
Problem
Now the problem is, we wanted to move this Network folder to Azure Blob or Sharepoint, but i can't any plugin, package or code, which can give me the same functionality.
Any thought and suggestion are welcome.
Regards
Aman

Opening a file (doc, pdf) via a button or hyperlink

I feel like I've gone in a thousand circles on this and it should be much simpler than it is, but basically I have this simple resume submission page in asp.net using C#. The files are on the server in a folder but it seems every solution I find just does nothing at all when I try to execute it.
Here's some examples of some of the things I've tried:
string folder = "~/App_Data/Resumes/" + Session["ResumeName"].ToString();
string folder2 = Server.MapPath("~/App_Data/Resumes/" + Session["ResumeName"].ToString());
System.Web.VirtualPathUtility.ToAbsolute(folder);
System.Diagnostics.Process.Start(folder2);
I'd never imagined something as simple as opening a document from a server would be so difficult. Is it not possible to just simply have a link to a document and have it opened when the user clicks it? That's all I want to accomplish. Thank you reading my through my frustration.
To clarify, System.Diagnostics.Process.Start(folder2); works locally, but doesn't work on the web server. I want this to work on the web server so that's why that one is out. I've tried to make it possible for the web server to open that file but I don't think I know enough about IIS to make it happen.
App_Data is a protected folder in ASP.NET. IIS will not serve anything from that folder directly to the client-- you will need to build a handler that serves the document directly.
Here are a few samples, though they aren't representative of everything you need to do. Others can feel free to add additional resources. Your handler would have to open the file and write it to the output stream:
Using a c# handler to serve up wav files cuts audio short (only a couple of seconds)
ASP.net cache ASHX file server-side
Don't use folders like App_Data to have your downloadable resources .
There is a similar question on stackoverflow which will give you a exact step by step answer - ASP.NET file download from server
From the title of your question, If I understand correctly you want to open a .doc or .pdf on a link or button click. This will open the respective document on the client.
<a id="lnkResume" href="#" runat="server" target="_blank">Download Resume</a>
And you can set the dynamic resume name from the code like below
string fileName = Session["ResumeName"].ToString();
lnkResume.HRef = Server.MapPath("~/App_Data/Resumes/" + fileName);

How can i set image link without adding it to my project?

I have a webproject where I want to read the Content/Images/Funny/ for all my funny images :-) I would want to generate a list in my controller of image urls and push it to the view.
How do I access it using relative path from project root? Dont want to use Server.MapPath since it will reveal my whole path on the server.
I started a new mvc3 project and Its Content folder I want to map up. Any hints?
in a controller's action, you can use
var path = new UrlHelper(Request.RequestContext).Content("~/Content/Images/Funny/");

Create a tableview with directories and files listing in monotouch

I'm trying to create a tableview that lists the files and directories in the documents folder. When a directory is selected it the app should then show the list of files in the selected directory. Its like nesting of tableviews. Unfortunately I am able to create a table view with the files in a specific directory only. I cannot make it list the directories and also list the files in the subdirectories.
I hope have made my objectives clear. Basically I just want to create a document/folder explorer using table view.
Please provide me with code if you can.
There's a few existing examples out there of how to achieve a recursive directory / file listing application using MonoTouch.
See example 1, an app to navigate up down folders and alert message on file click
And example 2, a worked example of how to navigate / recurse the files and folders using MonoTouch
Hope that helps you get on the right track.

Create Folder() Showing "<Result/>".But Folder are not getting created on Sharepoint

I would like to create a folder in Sharepoint 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:
<Result/>
No error. The second time I get the message:
<Error ID="13">AlreadyExists</Error>
But I do not see the folder on my website.
What am I doing wrong?
In another clown product from Microsoft, I just spend 4 hours on this exact problem. CreateFolder only works properly for document libraries, not form libraries. If you're trying to write to a form library, your documents are going to show up in another folder. For me, they were showing up in 'shared documents', even though I was specifying to create a folder under 'test'.
Take a look at documentation: Dws.CreateFolder Method (Document Workspace):
The following code example shows the use of the CreateFolder method to create a new subfolder in the default document library of the site. The absolute URL of the new folder is "http://server_name/sites/user_name/workspace_name/Shared Documents/folder_name".
So, you must check if you're using correct site address, under authenticated user_name.
Edit your web refrence config to include the proper path to your application.
Your config will look like this:
http://someserver/_vti_bin/Dws.asmx
Change it to
http://someserver/sub1/sub2/_vti_bin/Dws.asmx
dwsFolder.CreateFolder("Shared Documents/myNewFolder");

Categories