Search Results

Search found 6 results on 1 pages for 'qster'.

Page 1/1 | 1 

  • Why is XmlSerializer throwing an InvalidOperationException?

    - by qster
    public void Save() { XmlSerializer Serializer = new XmlSerializer(typeof(DatabaseInformation)); /* A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll A first chance exception of type 'System.InvalidOperationException' occurred in System.Xml.dll */ // .... } This is the whole class if you need it: public class DatabaseInformation { /* Create new database */ public DatabaseInformation(string name) { mName = name; NeedsSaving = true; mFieldsInfo = new List<DatabaseField>(); } /* Read from file */ public static DatabaseInformation DeserializeFromFile(string xml_file_path) { XmlSerializer Serializer = new XmlSerializer(typeof(DatabaseInformation)); TextReader r = new StreamReader(xml_file_path); DatabaseInformation ret = (DatabaseInformation)Serializer.Deserialize(r); r.Close(); ret.NeedsSaving = false; return ret; } /* Save */ public void Save() { XmlSerializer Serializer = new XmlSerializer(typeof(DatabaseInformation)); if (!mNeedsSaving) return; TextWriter w = new StreamWriter(Path.Combine(Program.MainView.CommonDirectory.Get(), Name + ".xml"), false); Serializer.Serialize(w, this); w.Close(); NeedsSaving = false; } private string mName; public string Name { get { return mName; } } private bool mNeedsSaving; public bool NeedsSaving { get { return mNeedsSaving; } set { mNeedsSaving = value; Program.MainView.UpdateTitle(value); } } private bool mHasId; public bool HasId { get { return mHasId; } } List<DatabaseField> mFieldsInfo; }

    Read the article

  • Generating a salt in PHP

    - by qster
    What's the best way to generate a cryptographically secure 32 bytes salt in PHP, without depending on libraries seldom included in typical PHP installations? After some googling I discovered that mt_rand is not considered secure enough, but I haven't found a suggestion for a replacement. One article suggested reading from /dev/random but not only this won't work on windows; it is also very slow. I want a reasonable balance between security and speed (ie, it shouldn't take 20 seconds to generate 512 bytes, like /dev/random usually does)

    Read the article

  • Algorithm to find the percentage of how much two texts are identical

    - by qster
    What algorithm would you suggest to identify how much from 0 to 1 (float) two texts are identical? Note that I don't mean similar (ie, they say the same thing but in a different way), I mean exact same words, but one of the two texts could have extra words or words slightly different or extra new lines and stuff like that. A good example of the algorithm I want is the one google uses to identify duplicate content in websites (X search results very similar to the ones shown have been omitted, click here to see them). The reason I need it is because my website has the ability for users to post comments; similar but different pages currently have their own comments, so many users ended up copy&pasting their comments on all the similar pages. Now I want to merge them (all similar pages will "share" the comments, and if you post it on page A it will appear on similar page B), and I would like to programatically erase all those copy&pasted comments from the same user. I have quite a few million comments but speed shouldn't be an issue since this is a one time thing that will run in the background. The programming language doesn't really matter (as long as it can interface to a MySQL database), but I was thinking of doing it in C++.

    Read the article

1