Jump to content
Xtreme .Net Talk

Diesel

Avatar/Signature
  • Posts

    682
  • Joined

  • Last visited

Everything posted by Diesel

  1. As in, not the code to do it, just an app? There's a ton out there, haven't used many. http://www.brothersoft.com/synchromagic-pro-39034.html http://www.download.com/Multi-FTP-Sync/3000-2160_4-10519045.html
  2. case "smtp_port": { int tmp; if (int.TryParse(data.ReadString(), NumberStyles.HexNumber, CultureInfo.CurrentCulture, out tmp)) { //property = tmp; } continue; } [/Code] DWORD stands for double word, or a byte.
  3. It depends on how you set up the code inside the loop to read the xml, and if you do a priming read. Here, the while(reader.Read()) statement serves as the priming read and the iteration read. What I mean by the priming read is that before the loop, the xml stream pointer points to nothing and the first read statement serves to move the pointer to something, usually the xml declaration. What I mean by the iteration read is that once an element is read...or not read, it increments the stream pointer. Actually, in this case, you can probably take out the reader.Read() at the bottom of the loop. That serves to increment the pointer if the element is not processed, which the while statement does. An alternative to while (reader.Read()) is to use a boolean variable and set it's value everytime reader.Read() is called inside the loop, ie. flag = reader.Read(); That way you can terminate the loop on any condition you choose. I prefer the flag. For completeness you can also add the default switch condition with just a break; body.
  4. There are a good number of ways to read xml with the .Net classes...and here is a clean, fast way. namespace XmlRead { using System; using System.Xml; class Program { static void Main(string[] args) { XmlReader reader = XmlReader.Create("data.xml"); while (reader.Read()) { if (reader.NodeType != XmlNodeType.Element) reader.MoveToContent(); if (reader.NodeType == XmlNodeType.EndElement) { reader.Read(); continue; } switch (reader.Name.ToLower()) { case "account_name": Console.WriteLine("account_name: " + reader.ReadString()); continue; } reader.Read(); } Console.ReadLine(); reader.Close(); } } } [/Code] Also, the recommend naming convention for XML tags is lower camel case, with no special characters, ie . hyphens.
  5. or the Coalesce function. http://msdn.microsoft.com/en-us/library/ms190349.aspx
  6. Yeh, let's get with the times here.
  7. Javascript rules. Haven't tried this, but nice webpage: http://www.livevalidation.com/ Did you contact the BBB about those Sears contractors?
  8. http://support.jodohost.com/showthread.php?t=1277 http://aspnetresources.com/blog/ie_validators.aspx
  9. You think that overwriting data is faster than writing data? Why? I don't see a point in filling up a file beforehand. Also, what happens if the download gets interrupted? How do you tell where the download left off? What if the actual file content contained streams of zeroes? I would say that having mechanisms that handle interruptions and failures is the most important part. Disk access performance is almost outside of your control, since you are using .Net. To answer your original question, using StreamWriter, the area of the file not written to was preserved. When you get some results, please share the knowledge. namespace FileOverwriteTest { using System.IO; class Program { static void Main(string[] args) { FileStream fs = new FileStream("test", FileMode.OpenOrCreate, FileAccess.Write); StreamWriter writer = new StreamWriter(fs); writer.Write(new string('0', 30000)); writer.Close(); fs.Close(); FileStream bs = new FileStream("test", FileMode.Open, FileAccess.Write); StreamWriter lwriter = new StreamWriter(bs); lwriter.Write(new string('1', 1000)); lwriter.Close(); bs.Close(); } } } [/Code]
  10. Are you not using the Contains function? No need to loop through. Anyway, the indexer syntax in C# uses []. I never remembered learning german. Not bad.
  11. First version, for readability, brevity.
  12. Re: Mouse Event Handling: Overlapping Controls Any solution you would find would be a hack. In Windows Forms, each control is a window, so moving the mouse over a button in a panel fires the MouseLeave event because the mouse is leaving the panel's client window and moving into the button client window. Drag&Drop events traverse up the ancestors and look for an object that can serve as a container. If you already have an easy way to find out if the mouse is in a container, I would recommend using that. Other than that, inheriting from a panel class, creating a boolean field indicating whether or not the mouse has left and performing logic in a function that checks to see if the mouse is in any of the child controls would work.
  13. Just throw up a web service. In .Net 3.0 there is the WCF framework for creating services and in 2.0 there is the web service namespace. Books: Programming WCF Services - Juval Lowy .Net Web Services -Keith Ballinger
  14. http://msdn.microsoft.com/en-us/library/wh45kb66(VS.80).aspx
  15. http://www.microsoft.com/downloads/details.aspx?FamilyID=e2c0585a-062a-439e-a67d-75a89aa36495&displaylang=en
  16. I'd like to prepend this post by saying that JavaScript is the $_hit, and in my opinion the most underrated language. <html> <head> <script type="text/javascript"> function AddTextAreaDOM() { var area = document.createElement('textarea'); document.getElementById('placeholder').appendChild(area); } function AddTextAreaString() { var div = document.getElementById('placeholder'); div.innerHTML += "<textarea />"; } </script> <body> <div id="placeholder"> </div> <input type="button" value="Add textarea with DOM" onclick="AddTextAreaDOM()" /> <input type="button" value="Add textarea w/o DOM" onclick="AddTextAreaString()" /> </body> </html> I would definitely recommend adding unique id's to the textarea's if you want to manipulate them later on. The only plumbing you need is the id or reference to a control you want to place the textarea in (or document.body).
  17. XNA is getting popular. Ok, now what about wcf, wf, wpf, linq forums.
  18. Diesel

    Class help

    Woops, yeh, didn't pick up that that was a class with a constructor. So, MrPaul, where is the compiler error then?
  19. Diesel

    Class help

    Well, I'll tell you what I think, see if that helps... First, the compile errors: dolgoszt d(file); What is the d? I don't think that's valid syntax in c++. Should just be: dolgoszt(file); and this one: adatok = new dolgozo[db]; Im pretty sure, this line: dolgozo *adatok; won't allow you to save multiple dolgozo structures into it. A pointer is a container for a certain size of object and you are defining a pointer to a memory space for 1 dolgozo object. In this case, you might as well use an array, since you instantiate it as an array (adatok = new dolgozo[db]; ). So, the change would be "dolgozo *adatok;" to "dolgozo adatok[];". And for the logic errors: 1. The dolgoszt function doesn't give any output on success, so I would assume you want to call the kiir function after the call to it in the main function. 2. I think that this is a never ending loop: while (!zh.eof()) { db++; } unless eof increments the file pointer....which I don't think it does. From what I see, you are trying to get the number of dolgozo structures in the file...You need to move the line before the while loop (zh.read((char*) &r, sizeof(dolgozo)); ) into the loop, so that the end condition will be met. That does seem very inefficient though, you might want to refactor that part.
  20. Why don't you get rid of the sizing grip... In WPF: ResizeMode=NoResize Winforms: BorderStyle= Fixed* Has anyone else noticed this post is from Sep 2007. I think he's figured it out by now.
  21. 2005 version works also.
  22. This line: Dim client As TcpClient = m_listener.AcceptTcpClient() ' Waits until data is available on the network is a blocking call. You even put a comment there to signify that it waits. An ugly way to cancel the blocking call would be to call m_listener.Close() in the ThreadStop() method. But, my recommendation would be to forgo threading in this case and use asynchronous callbacks, which are internally managed threads anyway. Use the BeginAcceptTcpClient method of TcpClient. Another tip, when writing debug information, include the namspace System.Diagnostics and use the Debug class.
  23. Try SelectTab() any difference, I would assume not. What else is going on in the application? Any eventhandling code hooked up to the controls in the TabControl? Show some code.
  24. Performance shouldn't be a factor. Each dll needed by the app gets loaded at run-time into the same Application Domain. Seperating common code into a seperate assembly sounds like a good idea in general. The general rule of design I would use in a situation like this would be, seperate what changes from what doesn't. If the data access code that you wrote isn't going to change from app to app, put it in a seperate dll, it allows the code to be reused effectively. In most applications I've worked with, we seperate the app into a ui layer, business logic layer and data access layer. What you seem to be talking about is the data access layer, and it is a very common scenario to put the code into a seperate assembly.
  25. A foreign key constraint says... for every entry in the child table, an entry in the parent table must exist. You can delete child records in SQL Server 2005 using 2 different methods: 1. A trigger 2. The CASCADE option As long as you have the authority to modify the table schema, I recommend using the CASCADE option. It is faster and does not require the maintenance of maintaining a trigger. ALTER TABLE Table2 ADD CONSTRAINT fk_id FOREIGN KEY (ID) REFERENCES Table1 (ID) ON DELETE CASCADE This will delete the corresponding child record whenever you delete a parent record. Make sure this is really what you want. I would offer another tip, that you create a unique primary key for table 2. Having multiple objects in the db accessible with the same key violates a normalization rule.
×
×
  • Create New...