how to upload a folder includes sub folders? [duplicate] - c#

I need something like the FileUpload control in asp.net that will allow the user to browse for a folder and enter a file name of a new file to upload.
From what I've seen FileUpload requires a file to be selected. It seems that html input type="file" has the same requirement.
Thanks!

Selecting an entire folder is not possible in FileUploadControl as it is meant for a single file. Although you can have a Multi File Selection. Multiple File Upload User Control

C# has build-in FTPrequest class where you can create folders, upload files, delete files etc.
If you want to upload folders from a webpage, you cannot use this technology in the browser, then you will have to use a rich-client such as Java, Flash or similar plugin.
If you can provide the users with a Windows or Mac client, you can use C# (either .NET or Mono) for the FTP transfer.
ZIP files arent a problem for ASP.net nor C#, but you still only upload 1 file (zip-archive) and then its up to the server to unzip it using eg. C#. Look at 7-Zip which is opensource, then you might get some ideas too.
You could also just try and use the build-in lib for it (compression):
http://www.eggheadcafe.com/community/csharp/2/10050636/how-to-compress-and-decompress-file-in-c.aspx
or try this link...
http://www.aurigma.com/docs/iu7/uploading-folders-in-aspnet.htm

Related

WPF C# Download Multiple Files

I can't seem to find any examples of downloading multiple files from a URL.
I have a URL lets say www.example.com/Document and I want to download all the files in that URL is that possible? or do I need to provide the name of each file in that URL? All the files would download to a folder specified here in the code.
Any examples of this would be great, this would be done by clicking a Download button in WPF.
The way I did this was to create a ZIP file and have all the files in there. You can either pre create a ZIP file and download or you can create the ZIP file as it downloads. I had to write my own software to do that but it does work.

Upload files to solr in C#

I am trying to make an application in Windows Form Application in C#. In my project I have added solr. I will upload files (json, xml, csv, txt, or database) and I will do the searching. I can do the filtering or searching by using solr in C#. However, the problem is I can't submit or upload the files to the system. For instance, I want to upload a database to the system. I have already done the query part so that I will do the filtering and searching. But as I said I can't do the file upload part.
I am doing my interface in C# so that I will not use the solr interface. Thats why, I need to submit/upload choosen file when button pressed.
Is there any way to do that?
Do you have any suggestion for me?
why don't you try uploading file to server & instead of saving file to the database!
while uploading a file, convert it into zip & then save it to the server folder, & save path of the file in the table.

.NET download one Zip file when files are on different server

my users upload their files in my Web Application and the application saves their files in the server that has the most free space. The result is that one folder of a user may contain multiple files that are saved in multiple servers.
Now i want to give my users the option to download their whole folder as a ZIP file.
Can somebody provide an appropriate namespace or guidance of what will be the best practice to achieve this functionality?
The application is written in C# .NET. So far i saw
1) http://msdn.microsoft.com/en-us/library/system.io.packaging.aspx
together with
2) http://msdn.microsoft.com/en-us/library/system.io.packaging.zippackage.aspx
Am i looking at the right direction?
Let say a user has his files over 3 servers named server1,server3 and server6
point 1. You must have those locations somewhere? right?
now suppose server7 needs to pack those files into 1 zip and stream to the client.
You will need to download all those files to server7 and then pack those files to zip archive.
To download the files you can use webrequest method. Hope this is clear.
YOU WILL NEED TO DOWNLOAD THE FILES TO A SINGLE LOCATION BEFORE ZIPPING THEM, there is no shortcut over this.

how to create an ASP.NET Web Page to manage folders and files for loading and reading to an external server?

I need to create a Web page that manages a shared folder, which means you can upload and download files, these preferably pdf and a certain size. This shared folder has security therefore must be accessed in any way with user key.
I need to know if there is some sort or some method easy to perform in ASP C#, give me options to view folders and their files created and upload new in a new folder.
I would appreciate your help and advice in order to make this website.
Use System.IO.DirectoryInfo and System.IO.FileInfo to work with a file system from .NET.
Using 'System.IO.FileStream' in one way to create new files from binary data (stream or byte[])
Easy way would be to use a third party control like FileUltimate
Or you can bulid your own custom file manager by using utility classes in System.IO and HttpResponse class for file streaming

How can I read an xml file from the users computer on an ASP.NET MVC2 site?

I am writing a website to consolidate a bunch of XML files with data into one MySQL database. I need to have a way to allow users to select a directory on their computer that contains a bunch of xml files. The site then reads each of those files and takes care of consolidating the information.
Is there a simple way (like the default open file dialog for win forms and wpf) to bring up a file dialog on a users computer, let the user pick a directory, and then be able to read the xml files in the selected directory? Would I have to upload them to the site temporarily first? Or could I just access them on the users computer?
Thanks!!
You can't access files from a webserver directly. You would need to write an ActiveX Control if you really don't find another way.
The standard conform way it just uploading one or more files with the browser fileupload:
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.fileupload.aspx
I would suggest that the user should zip the files and just upload the zip file.
There are some hacks - but I don't think it fits:
http://the-stickman.com/web-development/javascript/upload-multiple-files-with-a-single-file-element/
http://dotnetslackers.com/articles/aspnet/Upload_multiple_files_using_the_HtmlInputFile_control.aspx
I think you have to have a web dialog to upload the files to a temp location like you already mentioned and do the consolidation there before committing to your database. Or, maybe you can do the consolidation in JavaScript in the user's browser instance.

Categories