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
P

Paladin2000

@Paladin2000
About
Posts
156
Topics
24
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Any difference between Console App and Windows Service for HttpWebRequest..? [Solved]
    P Paladin2000

    I have solved the mystery... The problem was not in the code above, but in what was done with the response stream, which is in XML. Unfortunately, that XML contains a DTD that was causing the problem, when the XmlDocument class tried to retrieve it and failed (because it's not using the proxy credentials properly). And, of course, the "difference" was that in my console app I was just spitting the XML onto the screen, not loading an XmlDocument class. Thanks for the help for those who looked, though... :thumbsup:

    C# csharp json help question

  • Any difference between Console App and Windows Service for HttpWebRequest..? [Solved]
    P Paladin2000

    I understand what you are saying, but that is not the case here. The sevice is running under the same credentials used for proxy authentication; I changed it after I first installed the service by running services.msc and changing it on the "Log On" tab on the service's properties. I have run the console app under that account though, and it worked (unlike the service). What you're saying is valid, but it was already covered... But I'm still scratching my head on this. :confused:

    C# csharp json help question

  • Any difference between Console App and Windows Service for HttpWebRequest..? [Solved]
    P Paladin2000

    A good idea, and I tried running the console app under the same account as the service and it worked, so no change there. It always seems to run as a console app but never under the Windows service. I had previously done the reverse (run the service under the same credentials as I was using for the console app), but it did not work. Thanks...

    C# csharp json help question

  • Any difference between Console App and Windows Service for HttpWebRequest..? [Solved]
    P Paladin2000

    I am using an HTTP-based API to a 3rd-party service. Its usage involves two steps: POSTing a login command (which saves the session in a cookie), then issuing another command. I have tested this successfully in a console app, but when I try to use it in a (production) Windows service I am getting a 407 Proxy error back. Is there some difference between them regarding HttpWebRequests? I don't believe so but I'm scratching my head here.

    private WebResponse webPOST(string URLextension, string Parameters)
    {
    HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(BASE_URL + URLextension);
    request.ContentType = "application/x-www-form-urlencoded";
    request.Method = "POST";
    request.Headers.Add("X-Requested-With: C# Interface");
    request.CookieContainer = _cookieJar;
    request.Timeout = 3600000; //1 HOUR TIMEOUT
    if (_proxy != string.Empty)
    {
    request.Proxy = new System.Net.WebProxy(_proxy, false);
    request.Proxy.Credentials = new
    NetworkCredential(_proxyUser.ConvertToUnsecureString(), _proxyPass.ConvertToUnsecureString());
    }
    byte[] buffer = Encoding.GetEncoding("UTF-8").GetBytes(Parameters);
    Stream reqstr = request.GetRequestStream();
    reqstr.Write(buffer, 0, buffer.Length);
    reqstr.Close();
    return request.GetResponse();
    }

    The _cookieJar is a private property used to store the cookie generated by login. Both the login command and the "objective" command are issued via this private method, and the entire thing works with no errors in a console app.

    C# csharp json help question

  • Formatting bug in code block..?
    P Paladin2000

    Update: The pattern double-quote, backslash, backslash, double-quote was causing it. (I'm writing it out because I don't know if it will do something similar here.) I changed it to: @"\" which is the equivalent in C# and the problem went away.

    Site Bugs / Suggestions com help question

  • Formatting bug in code block..?
    P Paladin2000

    The text coloration on my last "tip" Zip archiving files after a cutoff date, but preserving directory structure[^] is making the code mostly "purple". Also, in IE this is causing the page to switch to Compatibility mode. I believe it is because I have two backslashes in double-quotes, and that is throwing it off somehow.

    Site Bugs / Suggestions com help question

  • How to make resistor color code
    P Paladin2000

    It's been a while since I've done component-level troubleshooting, but some of those color bands were *very* indistinguishable, especially when the manufacturer made them very thin. I remember browns and purples that were basically the same... Anyway, interesting program idea. :thumbsup:

    C# csharp help tutorial question

  • Oracle - odd behavior with nested select/join
    P Paladin2000

    I suspected something like that was happening. I've never used optimizer hints before; I will look into that. Thanks for the tip. :thumbsup:

    Database database oracle question

  • Oracle - odd behavior with nested select/join
    P Paladin2000

    Here is a strange result that I am getting with Oracle. Unless I wrap the select from TABLE1 as shown (specifying "rownum > 0"), the query never seems to complete. However, when it is included, it only takes a second or two. It doesn't make any sense to me, because all that it seems to do is force Oracle to evaluate the nested select with the alias "a" before performing the join. I had thought that placing it in parenthesis would do that automatically. Perhaps the Oracle optimizer does something wonky that this compensates for..? Scratching my head here, because all that the "where" condition adds is basically saying "give me any rows that you find".

    select COUNTRY_NAME, count(*) TALLY from
    (
    select * from (
    select IP_SOURCE_NUM from TABLE1
    where log_date between '01-JAN-2012' and date '01-FEB-2012'
    and IP_SOURCE_NUM > 0
    ) where rownum > 0
    ) a
    JOIN ip_geo b on b.ip_from =
    (
    select max(ip_from) as ip_from_match from ip_geo
    where ip_from <= a.IP_SOURCE_NUM
    )
    group by COUNTRY_NAME
    order by count(*) desc

    Database database oracle question

  • Something I just learned, with IP addresses
    P Paladin2000

    So here I was, trying to figure out why I was having problems with my ASP RegEx validator control. The objective was to match to an IP address, but to allow it to end in "*" in the final octets (that is, 255.255.255.255 is valid, and so is 255.255.255.* or 255.255.*.* or 255.*.*.*). But the validation was failing for 0.0.0.200, or anything over 199 in the last octet. Here is what I had:

    ValidationExpression="((1?\d?\d)|(2[0-4]\d)|(25[0-5]))\.(([*]\.[*]\.[*])|(((1?\d?\d)|(2[0-4]\d)|(25[0-5]))\.(([*]\.[*])|(((1?\d?\d)|(2[0-4]\d)|(25[0-5]))\.([*]|((1?\d?\d)|(2[0-4]\d)|(25[0-5])))))))"

    Here is the fix:

    ValidationExpression="((25[0-5])|(2[0-4]\d)|(1?\d?\d))\.(([*]\.[*]\.[*])|(((25[0-5])|(2[0-4]\d)|(1?\d?\d))\.(([*]\.[*])|(((25[0-5])|(2[0-4]\d)|(1?\d?\d))\.([*]|((25[0-5])|(2[0-4]\d)|(1?\d?\d)))))))"

    By reversing the order (priority) of the octet matches, I solved the problem...

    Regular Expressions regex help question

  • GZipStream appears to malfunction (24K maximum)
    P Paladin2000

    Update... The .gz appears fine; I was able to extract it using WinZip (224 MB -> 877 MB). I tested Ionic's version of GZipStream, and it also resulted in a 24K file, along with the following error message: Destination array was not long enough. Check destIndex and length, and the array's lower bounds. Here is the Ionic-GZipStream version (which is almost identical to the previous):

    /// <summary>
    /// G-ZIP (.gz) Decompression method, using Ionic library. Places new file in the same folder.
    /// </summary>
    /// <param name="file">File to be decompressed.</param>
    private static void gDecompressIonic(FileInfo file)
    {
    // Get the stream of the source file.
    using (FileStream inFile = file.OpenRead())
    {
    // Get original file extension, for example "doc" from report.doc.gz.
    string curFile = file.FullName;
    string origName = curFile.Remove(curFile.Length - file.Extension.Length);

        //Create the decompressed file.
        using (FileStream outFile = File.Create(origName))
        {
            using (Ionic.Zlib.GZipStream Decompress = new Ionic.Zlib.GZipStream(inFile, Ionic.Zlib.CompressionMode.Decompress))
            {
                //Copy the decompression stream into the output file.
                byte\[\] buffer = new byte\[4096\];
                int numRead;
                while ((numRead = Decompress.Read(buffer, 0, buffer.Length)) != 0)
                {
                    outFile.Write(buffer, 0, numRead);
                }
            }
        }
    }
    

    }

    C# csharp com tutorial question

  • GZipStream appears to malfunction (24K maximum)
    P Paladin2000

    Well, I have it attempting to decompress a collection of .gz files which are generated as output from a 3rd-party application. However, since I don't see anyone else (via Google search) having this problem, I shall assume it is either (1) something odd about how the 3rd-party source is (mis)creating .gz files, or (2) something is wonky elsewhere with the code. #2 seems unlikely, as this is a static method that only takes a FileInfo as input. It seems fairly self-contained. However, my next step is to create a tiny app that I can test this with (in better isolation from the "other stuff" in my code), as well as a parallel test using something like SharpZIPlib to see if there is any difference. Thanks...

    C# csharp com tutorial question

  • GZipStream appears to malfunction (24K maximum)
    P Paladin2000

    I am getting an odd result when trying to decompress .gz files... The method that I am using only decompresses the first 24KB of the file, but the actual content is over 100 MB. I am using .NET 3.5, with the decompression method from the MSDN article (copied below). Has anyone seen this odd behavior before..?

    /// <summary>
    /// G-ZIP (.gz) Decompression method. Places new file in the same folder.
    /// </summary>
    /// <see cref="http://msdn2.microsoft.com/en-us/library/system.io.compression.gzipstream.aspx"/>
    /// <param name="file">File to be decompressed.</param>
    private static void gDecompress(FileInfo file)
    {
    // Get the stream of the source file.
    using (FileStream inFile = file.OpenRead())
    {
    // Get original file extension, for example "doc" from report.doc.gz.
    string curFile = file.FullName;
    string origName = curFile.Remove(curFile.Length - file.Extension.Length);

        //Create the decompressed file.
        using (FileStream outFile = File.Create(origName))
        {
            using (GZipStream Decompress = new GZipStream(inFile, CompressionMode.Decompress))
            {
                //Copy the decompression stream into the output file.
                byte\[\] buffer = new byte\[4096\];
                int numRead;
                while ((numRead = Decompress.Read(buffer, 0, buffer.Length)) != 0)
                {
                    outFile.Write(buffer, 0, numRead);
                }
            }
        }
    }
    

    }

    C# csharp com tutorial question

  • when i delete my program (in C#) the database still exists - how to delete him ?
    P Paladin2000

    What you say?!

    C# csharp database tutorial question

  • Gem code
    P Paladin2000

    I think the code is attempting to do something like this:

    public int SomeValue {get; private set;}

    The Weird and The Wonderful ruby asp-net

  • Test-driven voodoo magic
    P Paladin2000

    Perhaps you could set the server on a nice, comfortable couch and have a psychologist discuss the "daddy issues" with the code, due to inept "parent" programmers..? Same thing.

    The Weird and The Wonderful database wcf sysadmin business regex

  • What a gem.
    P Paladin2000

    The "+" operator does work here, it implicitly converts the number to a string and concatenates it to the other. But yes, the "&" operator is for concatenation explicitly. However, in your example, my key point was that you used the "*" operator between a number and a string...

    The Weird and The Wonderful ruby com

  • What a gem.
    P Paladin2000

    Actually, it's:

    Return (SystemInformation.PowerStatus.BatteryLifePercent * 100).ToString() + "%"

    You did the ToString before the multiplication. Note that this:

    SystemInformation.PowerStatus.BatteryLifePercent.ToString("p")

    ...does create a percentage conversion, but since it has decimals and a space it is not equivalent.

    The Weird and The Wonderful ruby com

  • C# help?
    P Paladin2000

    I will agree with Pete in your last posting - "This is fairly basic stuff". Perhaps you could look into a few online tutorials? That would probably help you to learn this better than asking several questions here. Rather than trying to make a given block of code work, I would advise to learn the fundamentals instead...

    C# csharp help question

  • Windows 7: Automatic file delete?
    P Paladin2000

    I'm not sure if there is a better forum for this one :confused: - but I will put it here because the plug-in is written in C#... I have an Outlook 2010 plug-in that I created, with a deployment solution. After installing it via the MSI file, there is a configuration file that must be manually copied to its installation folder,

    C:\Program Files\\

    The odd thing is, one of my colleagues reported that his file "vanished" from the folder. Today, the same thing happened on my machine. Both are running Windows 7 (one machine is 32-bit, the other 64). I checked my Recycle Bin, and it was not there either. Does Windows 7 have some protective feature that removes files from protected directories automatically? I do know that Administrator rights are required to copy to that location.

    C# csharp sysadmin question workspace
  • Login

  • Don't have an account? Register

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