Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
T

tommazzo

@tommazzo
About
Posts
35
Topics
10
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Overwrite one section of binary file
    T tommazzo

    I see. Thanks for your help guys!

    C# question

  • Overwrite one section of binary file
    T tommazzo

    Hi! I have a binary file that contains strings one after the other and I want to replace a string at offset x. The existing string is, let's say 10 bytes long, but the new one is 12 bytes long. How do I replace the old string at position x without overwriting the first 2 bytes of the next string and without rewriting the entire binary file from offset x. Thanks already in advance!

    C# question

  • Fastest way to read XML
    T tommazzo

    I don't think I'll ever have to change the type of a property, my only concern was newly added properties. Thanks for clearing this up for me!

    C# xml question

  • Fastest way to read XML
    T tommazzo

    Thanks, I didn't think of the XmlIgnore attribute. Just out of interest, if I added a property, would XmlSerializer still be able to read files that did not have that property yet?

    C# xml question

  • Fastest way to read XML
    T tommazzo

    Normally that would be an idea, however I don't have to serialize all of my class' properties. Those that need not be serialized are actually created from the serialized ones. So XmlSerializer is unfortunately out of the question for me.

    C# xml question

  • Fastest way to read XML
    T tommazzo

    Hi! If I have a class with a certain number of properties, which I want to save to an XML file, where it is critical that the data can be read back into the variables as fast as possible. My idea is to create an XmlTextReader and then read the values as follows: while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element) { switch (reader.LocalName) { case "Prop1": m_Prop1 = reader.ReadString(); break; case "Prop2": m_Prop2 = reader.ReadString(); break; case "Prop3": m_Prop3 = reader.ReadString(); break; case "Prop4": m_Prop4 = reader.ReadString(); break; case "Prop5": m_Prop5 = reader.ReadString(); break; case "Prop6": m_Prop6 = reader.ReadString(); break; default: break; } } } I just want to make sure that I am in fact using the fastes possible way. So can anyone think of anything faster? Thanks already in advance!

    C# xml question

  • Problem with ByValue Parameters
    T tommazzo

    You could implement the IClonable interface in your PictureBox class. This interface is used to create a copy of an object, but you would still have to write the attribute copying code in there.

    C# question help

  • Read non standard conformant XML
    T tommazzo

    Has anybody got an idea? It's quite urgent.

    C# question xml help tutorial

  • Read non standard conformant XML
    T tommazzo

    This could of course be an approach, but as some of the files are quite big, performance would suffer a lot. Isn't there a way that I can configure XmlReader to forget about any kind of character encoding?

    C# question xml help tutorial

  • Read non standard conformant XML
    T tommazzo

    Hi! I want to read an XML file, which is not completely standard conformant. To be more precise some of its nodes contain text with special characters (see the example below). <RootElement> <ConformantNode>Hello</ConformantNode> <NonConformantNode>You & me</NonConformantNode> </RootElement> As you can see "NonConformantNode" contains an & char in its text, which always makes System.Xml.XmlReader throw an exception. How can I read the content of this document, in other words, how can I read an XML document without automatic character decoding? Thanks for your help in advance! P.S.: I already tried setting XmlReaderSettings.CheckCharacters to false, but this doesn't do the trick. -- modified at 8:01 Saturday 17th September, 2005

    C# question xml help tutorial

  • Make control part of Window
    T tommazzo

    That's exactly what I'm already doing. I create a new HWND with CreateDialogParam() and specify my parent window handle as hWndParent. Yet the newly created HWND is NULL and GetLastError() returns 0 (:confused:). Here is an exerpt of the .rc file: IDD_PVIEWERPANE DIALOGEX 0, 0, 443, 154 STYLE DS_CONTROL | WS_CHILD | WS_VISIBLE FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN GROUPBOX "Photo information",IDC_STATIC,7,7,429,140 LTEXT "Title:",IDC_STATIC,13,32,44,8 LTEXT "Static",IDC_TITLE,61,32,98,8 LTEXT "Time taken:",IDC_STATIC,191,32,62,8 LTEXT "Static",IDC_TIMET,255,32,118,8 LTEXT "Path:",IDC_STATIC,13,47,34,8 LTEXT "Static",IDC_PATH,55,47,381,8,SS_ENDELLIPSIS LTEXT "Dimensions:",IDC_STATIC,13,61,67,8 LTEXT "Static",IDC_DIMENSIONS,81,61,120,8 LTEXT "Zoom factor:",IDC_STATIC,228,61,79,8 LTEXT "Static",IDC_ZOOMF,315,61,98,8 CONTROL "",IDC_RICHEDIT21,"RichEdit20A",ES_AUTOHSCROLL | WS_BORDER | WS_TABSTOP,7,78,429,69,WS_EX_CLIENTEDGE PUSHBUTTON "< Previous",IDC_BPREV,13,17,79,14 PUSHBUTTON "Next >",IDC_BNEXT,357,17,79,14 END ... IDD_PVIEWERPANE, DIALOG BEGIN LEFTMARGIN, 7 RIGHTMARGIN, 436 VERTGUIDE, 13 TOPMARGIN, 7 BOTTOMMARGIN, 147 HORZGUIDE, 17 HORZGUIDE, 31 HORZGUIDE, 40 END ... ... and here's my code: HWnd = CreateWindow(C_PHOTOVIEWER, "", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, PANEWIDTH, 500, NULL, NULL, hInst, NULL); SetWindowLongPtr(HWnd, GWLP_USERDATA, (LONG_PTR) this); hPane = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_PVIEWERPANE), HWnd, this->DlgProc, (LPARAM) this); ShowWindow(HWnd, SW_SHOW);

    C / C++ / MFC question csharp visual-studio learning

  • Make control part of Window
    T tommazzo

    Hi! I just created a control with the dialog designer in Visual Studio (added dialog resource and set the Control property to true - adds DS_CONTROL flag). How do I make this control part of a window that I create with CreateWindow()? Thanks already in advance!

    C / C++ / MFC question csharp visual-studio learning

  • Which is the fastest pattern matching algorithm
    T tommazzo

    Thanks a lot! I'll give it a try.

    C# algorithms regex question

  • Which is the fastest pattern matching algorithm
    T tommazzo

    Hi! I'm looking for a way to find the position of a certain pattern within a string. On my search on the internet I've come accross various algorithms such as Knuth-Morris-Pratt and Boyer-Moore (just to name two). But which is the fastest?

    C# algorithms regex question

  • == or String.Equals()
    T tommazzo

    Due to some misconfiguration in my Profiler I originally thought op_Equality() to be faster, which in fact isn't the true case. Apparently the null checking that is performed in op_Equality() makes it a little slower than Equals(). Thanks for your help!

    C# com xml performance question code-review

  • Edit TreeNode text ???
    T tommazzo

    Just set the LabelEdit property of your TreeView to true and you'll be able to edit it by clicking on it. If you want to trigger an Edit manually use TreeView.BeginLabelEdit().

    C# csharp data-structures help tutorial question

  • == or String.Equals()
    T tommazzo

    Hi! I'm currently trying to improve the speed of my xml library TXML, which does not rely on any XML base classes and thus parses the XML string itself to find a certain node. Because of this I'm interested in finding the fastest way of checking the equality of two strings. On various sites I've read that String.Equals() is supposed to be faster than the == operator, which uses String.op_Equality() under the hood. So I replaced all == comparisons in a certain method with String.Equals() comparisons. The weird thing is that the new code with String.Equals() appears to run 100 ms on average slower than the old code with ==. Can anyone explain me why? Here's the code of the above mentioned method: private ReaderReturnValue GetNodeContent(string masterNode, int mnIndex, string subNode, int snIndex) { int mi = 1; // masternode iterator int si = 1; // subnode iterator int mnLength = masterNode.Length; int snLength = subNode.Length; int textLength = 0; // the length of the text that is to be returned int i = 0; // the for iterator int snBegin = 0; // the beginning pos of the subnode bool foundMn = false; bool foundSn = false; bool done = false; // indicates if we have found the nodes and the text length if(masterNode == "") // if there is no masterNode specified set foundMn to true foundMn = true; for(i = 0; i < XmlText.Length; i++) { if(XmlText[i] == '<') // are we currently inside a node? { if(foundMn == false) // do we have to search for our masternode? { if(mnLength + 1 <= XmlText.Length - i - 1) // only continue if we haven't reached the end yet - aka if there are enough chars left to read { if(XmlText.Substring(i + 1, mnLength + 1).Equals(masterNode + '>')) // have we found our masternode? { if(mi == mnIndex) foundMn = true; else mi++; } } } if(foundMn == true

    C# com xml performance question code-review

  • Shut down explorer programmatically
    T tommazzo

    Ian Bowler wrote: The C++ code in the original post shuts down explorer indefinately. Is the limitation a C# limitation? This is, I believe, because you sent the process the WM_QUIT message, with Process.Kill() you kill it without sending it the WM_QUIT message. In order to keep explorer from restarting you could either run a loop on a new thread, which continously checks if explorer has been restarted and kills it again if neccessary (this isn't really the best idea). Or (and this should be the better idea) you could import the FindWindow and PostMessage methods with DllImport and use them the same way as in C++;

    C# csharp c++ linux tutorial question

  • Shut down explorer programmatically
    T tommazzo

    You can do this using the System.Diagnostics namespace. The following code will kill explorer.exe: Process[] RunningProcesses = Process.GetProcessesByName("explorer"); Process proc = new Process(); foreach(Process p in RunningProcesses) { if(p.ProcessName == "explorer") { proc = p; break; } } proc.Kill(); When I tested it however explorer.exe restarted a few seconds after it was killed. This might be due to some program I had running, but I'm not sure.

    C# csharp c++ linux tutorial question

  • Making string HTML compliant
    T tommazzo

    Thanks a lot! That was exactly what I meant. Although I must say that HttpServerUtility is only usable from within an ASP.NET application, for normal Windows apps HttpUtility has to be used.

    C# html
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups