C# easiest way of storing strings to external file - c#

C#
TL;DR: I want the user to be able to input text, which is then written to an external file, which then can be called later based on position in the file. What's the easiest way and form to read and write a list of strings to?
Very amateur question, but I can't seem to find an easy anwer on the internet. If I'm missing something obvious, please redirect me. I am writing a very simple program in which the user can input a string which is then written (added) to an external file, from which later a string can be called based on the position in the file. I found things like JSON, Resource file, SQL DB... Problem is that due to my lack of programming experience I have no idea what's the best option to look into.
Example of what I want to achieve:
User inputs strings 'Dog', 'Cat', and 'Horse' into the textbox. Each of these strings are added to the external file. Lateron, the user calls the 2nd number on the list, to which the program returns 'Cat'.
Thanks!

If you already know the kind of data that will be saved I recommend using XML Serialization. This lets you save and read your file very easily. The linked example is from Microsoft and shows a dataset being serialized. If you want to save a generic list instead of a fixed object you might find this link helpful.
Alternatively, you could save data to your application configuration file (search online for "C# application configuration for PROJECT_TYPE" where the project type is winforms/mvc/class library etc..)

Related

Creating .resource file in windows forms

I am trying to create a .resource file which will contain all the strings being used in the application. I don't want to do it manually.
I know there are certain ways to do it. But my problem is, I don't want to have it done manually, where I need to add each string resource. Is there a way to do this without I having to put each string, and it automatically detects all the strings resources corresponding to different pages.
Any insights on this would be helpful.
Yes, there is a way to do this.
You can try with R#, although the tool is commercial, there is a 30-days trial period.
As a regular user, I can tell you that it worth every cent.
There are suggestion for every string, and moving to the resource file is accomplished by one click.

Real time editor for Cloud Storage System

I am working on cloud storage system in ASP.Net MVC5. In which I made a file manager that handles cut,copy,download multiple files,edit and preview of files, but I want to edit documents like word files in real time (collaborative editing)..is there any api that can help me accordingly.
Thank you in advance.
you should use Signal R for real time applications...it may be possible with the help of application user interface but its better to write your own code according to your choice...
[http://signalr.net/][1]
dev_express and syncfusion may be your solution..try these..
This is turning into a huge comment, so I'll just explain my point of view in an answer. I'll remove it, if I see an actual answer appears.
I am suggesting you start writing your own code for collaborative editing and the reason is quite simple. You need at least slightly different processing for almost each file type, which suggests there will never be a single API to support collaborative editing for all file types, unless somebody makes it their goal to maintain it and keep up with every one created.
Start it simple, text (or hex) editing. Define how changes are made and implemented on other clients and then work your way to add as many file types (and methods that go with them) as you need.
You could use source code of 1 of these open source collaborative text editors (you'll have to find download / Github links on their websites) to get a general idea how to do it, but you will still have to put in some work and won't go far without creating your own code.
Collaborative editing requires user 1's (who just started editing) client to send either one of these:
Data pointing to changes made in file
Full file, and user 2's client (or central "server") should be able to calculate the changes made from there and implement them.
One of the problems is to overwrite only that portion of the file changes were made to (and avoid overwriting the other user 2's work).
And the biggest problem (the reason you can't have "1 for all" method/API) is each file type has its own structure meaning that different file types will have different data representing changes in file. If you try to write raw data it might work, but you'd still need to calculate and lock away specific portions of file, that contain general information, rather than data of your file.

Translating comments and region names in source code

Does anyone know of a batch processor or a VS 2010 plugin/script that would let me translate comments and region names from Chinese into English?
The only ones I've found either process all strings or only one string at a time.
I have two large C# projects that I am trying to read through.
Thanks.
Use PrepTags to prepare your file for translation. It will allow you to select the text to be translated based on regex.
www.preptags.com
You can work file by file for free, or process the files as batch using the pro version (€39)
In your case, it's pretty simple to prepare. You just mark everything as protected, then unprotect the content of the comments & region names.
Disclosure: I develop PrepTags.
As was noted, you can use Google Translate API or alternatively Bing Translator API. You can detect comments and regions in your files using System.CodeDom.
I'm not too sure if this is possible. What you can do to help would be the following:
1) Make sure that both C# projects have the Properties > Build > Xml document file check box checked.
2.1) Write an application that reads in the generated xml file.
2.2) Parse the file, and for each value make a call to Google Translate to get the translated value.
2.3) Place the translated value within another xml file that has the same structure as the one created from building the project.
This wouldn't solve the your desire to translate the region names, but its a start. At least you would have intelligence when using the two projects.
This is actually a good idea for a small open source project. I may decide to pick it up. If I do, I'll let you know.

Loading a XML file and injecting data into a table and return it as a navigation/tableview

So here's the situation: I have a friend who wants me to make an app for his comic website, he wishes for me to set it up so the comics appear in a tab (navigation and tablelist/view). Im not sure what the best method for his XML file is, i do know of the xml code on how do it, but unfortunately, i do not know nor have ever used the code for it.
so im sorta lost, this is the file: http://hoshen.controlshiftblack.com/HoshenFeed.xml
And does anyone have any simple to use suggestions for using XML in an app?
There are saveral ways to get the job done, you can use an xml library and make a parser for your xml feed like
NSXML
http://deusty.blogspot.com/2008/09/nsxml-on-iphone.html
or libxml
http://iphonedevelopment.blogspot.com/2008/04/simplifying-libxml.html
Also there are third party parsers that allow you to use Objective-c objects, one widely used is
GData
http://feedproxy.google.com/~r/RayWenderlich/~3/YuSy-Gey1sg/how-to-read-and-write-xml-documents-with-gdataxml
If that's not enough, ask your friend to send you JSON data instead and use a JSON library for iPhone
http://maniacdev.com/2010/07/using-objective-c-json-to-do-translations-in-an-ios-app/

Windows App spellcheck

I was wondering if there is another way to spell check a Windows app instead what I've been of using: "Microsoft.Office.Interop.Word". I can't buy a spell checking add-on. I also cannot use open source and would like the spell check to be dynamic..any suggestions?
EDIT:
I have seen several similar questions, the problem is they all suggest using open source applications (which I would love) or Microsoft Word.
I am currently using Word to spell check and it slows my current application down and causes several glitches in my application. Word is not a clean solution so I'm really wanting to find some other way.. Is my only other option to recreate my app as a WPF app so I can take advantage of the SpellCheck Class?
If I were you I would download the data from the English Wiktionary and parse it to obtain a list of all English words (for instance). Then you could rather easily write at least a primitive spell-checker yourself. In fact, I use a parsed version of the English Wiktionary in my own mathematical application AlgoSim. If you'd like, I could send you the data file.
Update
I have now published a parsed word list at english.zip (942 kB, 383735 entries, zip). The data originates from the English Wiktionary, and as such, is licensed under the Creative Commons Attribution/Share-Alike License.
To obtain a list like this, you can either download all articles on Wiktionary as a huge XML file containing all Wiki- and HTML-formatted articles. This is then more or less trivial to parse. Alternatively, you can run a bot on the site. I got help to obtain a parsed file from a user at Wiktionary (I seem to have forgotten his name, though...), and this file (english.txt in english.zip) is a further processed version of the file I got.
http://msdn.microsoft.com/en-us/library/system.windows.controls.spellcheck.aspx
I use Aspell-win32, it's old but it's open source, and works as well or better than the Word spell check. Came here looking for a built in solution.

Categories