Upload files to solr in C# - 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.

Related

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

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

Show XML in WebBrowser without save temp file

I have a Silverlight application where I need to show a XML content in a TextBox or in a WebBrowser control, but this XML is stored compressed in database.
I found some tutorials and questions where people take the XML string, save it on temporary file then calls the Navigate method, passing this temporary file path. However, my application is Silverlight on client side, so I may have permissions problems storing temporary files on user's machine.
Showing the string in a TextBox it's an option, but the problem is that the XML content may be compressed,so it's difficult to read.
I know I can save this file on server, then deliver this file URL to my Silverlight application, then open a Browser window, but I'm just looking for a simple solution to do entirely on client side.
Is there some simple way to format(uncompress) this XML, or a simple way to open this string in WebBrowser as XML wihout saving a temporary file?

Building Excel uploader in MVC, Should I save Excel file to db or file/web server?

I allow user to upload one excel file at a time. After the upload, the code will validate then save portions of the excel file to an existing database (sql server).
Should I save the excel file to the db, then pull it out and process it, or is it better to save to a temp directory on the web server, process/save the data, then delete the file?
Edit: If I end up saving the file to the DB, is it better to go the binary route (save to byte array, then save) or can I use a regular string array or file stream?
In my personal opinion its best to do this approach.
The answer will be based on your requirement, since you said you will process whats inside excel then this is my suggestion.
Save the file in a file/web server
Save the path of the file saved in SQL Server
Here is why:
To process the file from your code will be easy no need for additional process to access the file and no special coding needed.
You can physically access the file if needed.
Putting files on the database will increase its load, huge possibility of slowing your whole application down.
Database will be bigger so back ups will be slower
Talking about costs, DB strorage is more expensive than file system storage

Saving data into files and reload them later

I am working on a WPF project with C#.
There is a MainWindow and some other windows showing some data. I have also three XML files, where data from lists can be saved. The code is all written and works perfect.
Now my question is, how to save the whole file. I want to have the capability to, for example, save all the data into files, and user can open these files later and load the data into lists, and commence working, where they left the application before.
Can anybody help me?
If I understand your question correctly, you need to do it with following steps:
Save your XML files with a specific extension name.
you can achieve this by many ways: e.g. you can save your actual XML files into a location, and then just create a link file that contents links to these files. Or you can ZIP all the XML files into one single file.
link the default extension name to your application (so it will be opened by your application by default)
Open/read the file with XML content from your application.
Check this
Deserialize XML into items and display them in your list.

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