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
S

ShadowUz

@ShadowUz
About
Posts
29
Topics
13
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • How to close (kill, release?) a socket, which is in FIN_WAIT_2 state?
    S ShadowUz

    Yes. I know that the server is not sending ACK to the client signaling that the socket is closed. The problem is I don't have access neither to server nor client code. The only solution I am seeing here is releasing the ports by force. In POSIX, there is a system call (linger?) to close ports. I am looking something like this for Windows, if it exists.

    C# sysadmin visual-studio debugging tutorial question

  • How to close (kill, release?) a socket, which is in FIN_WAIT_2 state?
    S ShadowUz

    I have a client application, which uses a unmanaged dll for communicating with a server. All network-related operations are perormed inside the unmanaged dll. After a number of operations with the server, the client is running out of TCP ports. If we check the state of netwotk using 'netstat -an', we get the following result:

    ...
    TCP 192.168.11.55:56048 192.168.10.28:5000 FIN_WAIT_2
    TCP 192.168.11.55:56049 192.168.10.28:5000 FIN_WAIT_2
    TCP 192.168.11.55:56050 192.168.10.28:5000 FIN_WAIT_2
    TCP 192.168.11.55:56051 192.168.10.27:5000 FIN_WAIT_2
    TCP 192.168.11.55:56052 192.168.10.28:5000 FIN_WAIT_2
    TCP 192.168.11.55:56053 192.168.10.27:5000 FIN_WAIT_2
    TCP 192.168.11.55:56054 192.168.10.27:5000 FIN_WAIT_2
    TCP 192.168.11.55:56055 192.168.10.27:5000 FIN_WAIT_2
    TCP 192.168.11.55:56056 192.168.10.27:5000 FIN_WAIT_2
    TCP 192.168.11.55:56057 192.168.10.28:5000 FIN_WAIT_2
    TCP 192.168.11.55:56058 192.168.10.27:5000 FIN_WAIT_2
    TCP 192.168.11.55:56059 192.168.10.28:5000 FIN_WAIT_2
    TCP 192.168.11.55:56060 192.168.10.27:5000 FIN_WAIT_2
    ...

    The ports are released only after the client is closed. If I run the VS project in Debug Mode, it never runs out the ports. But, while running in Release mode, it is happening. How to release or kill those ports which are in FIN_WAIT_2 state?

    C# sysadmin visual-studio debugging tutorial question

  • How to Override FileSystemInfo Class Readonly properties (Exists, Extension, Name, and etc)?
    S ShadowUz

    I am using a C++ DLL, where one of the parameters is a FileSystemInfo Class. The problem is, I am retrieving all file properties from a server. And have to assign all the properties to the class and return it to C++ DLL. I have tried to create my own FileSystemInfo class with {get; set} properties, but getting this error:

    Cannot convert MyClass.MyFileSystemInfo to System.IO.FileSystemInfo

    C# help c++ sysadmin tutorial question

  • syslog.h analog in WIndows
    S ShadowUz

    Hello. I'm porting a *nix C code to Windows using MingW. Having trouble with syslog.h. Is there any syslog.h analog in Windows so that I could include the headers like:

    #ifdef WIN32
    #include #else
    #include #endif

    ? Thank you.

    ATL / WTL / STL question

  • How to detect invalid character input in ListView control?
    S ShadowUz

    Thank you for the reply. But I can't make use of this method as I need a real-time check for user input.

    C# tutorial question

  • How to detect invalid character input in ListView control?
    S ShadowUz

    How to detect invalid character input in ListView control? I want to detect invalid character input while editing a ListBox's item and show a tooltip with warning. I know how to do it for TextBox control:

    private void textBox1_TextChanged(object sender, EventArgs e)
    {
    ToolTip myTooltip = new ToolTip();
    if (textBox1.Text.Contains("Invalid Character"))
    {
    myTooltip.Show("You entered an invalid character", textBox1);
    }
    }

    How to make it for a ListBox control? Thank you.

    C# tutorial question

  • How to send filenames containing '#' to WebDAV Server
    S ShadowUz

    Thank you. This is really a helpful method.

    C# tutorial sysadmin linux

  • How to send filenames containing '#' to WebDAV Server
    S ShadowUz

    I do use HttpUtility.UrlEncode(). But it's not replacing # to %23, simply, leaving it as it is. So, I replaced # to %23 manually. Now it's working. Thank you.

    C# tutorial sysadmin linux

  • How to send filenames containing '#' to WebDAV Server
    S ShadowUz

    Hello. I'm trying upload a file which name contains '#', for example: '#1.doc', or 'myFile#125.exe' to WebDAV Server, which is running on Linux. I use HttpUtility.UrlEncode() Method for encoding URL, but everytime the result will be files with name '1.doc' and 'myFile' on the server. Please, give some advice. Thank you.

    C# tutorial sysadmin linux

  • Sending HttpWebRequest with a Unicode string
    S ShadowUz

    Thank you for the answer. Yes. You are right. I could have encoded the Unicode characters and URL using HttpUtility.UrlEncode Method. But the problem is, it is implemented only in .Net 4.0, but unfortunately, I'm writing my program in .Net 3.5 do to the compatibility with "a little bit old OSs" with older versions of .Net. Still did not find a proper solution. That was totally wrong. I tried to use HttpUtility.UrlPathEncode(str) method directly without adding reference to the System.Web Namespace in project's properties:

    ...
    using System.Web;
    ...
    string convertedPath=HttpUtility.UrlPathEncode(path);
    ...

    And after adding reference, I did like this:

    ...
    string convertedPath=System.Web.HttpUtility.UrlPathEncode(path);
    ...

    and it worked. Thank you guys!

    C# help csharp com tutorial question

  • C# Windows Service
    S ShadowUz

    Hi. Sometimes it happens that your thread which is responsible for creating XML files tries to read the arrived text file when it's not completely free (some service is still using it). Try to wait for some milliseconds before attempting to open the text file like this:

    Thread.Sleep(100);

    I hope this will work.

    C# csharp xml help

  • Why exception is not caught in BackgroundWorker DoWork routine?
    S ShadowUz

    As you did not present any code, I assume that you are having a problem with Control.Invoke Method (Delegate) method. The exception is not thrown if you try to change some control's properties directly from inside a thread. For example:

    private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
    {
    ChangeMyText("Privet");
    }

        private void ChangeMyText(string myText)
        {
            label1.Text = myText;
        }
    

    The result will be a dead backgroundWorker. It will not say anything but die when it reaches

    label1.Text = myText;

    and will not throw an exception. Instead, you have to use

    label1.Invoke((Action)delegate
    {
    label1.Text = myText;
    });

    ____________ Ulugbek

    C# csharp data-structures question

  • Sending HttpWebRequest with a Unicode string
    S ShadowUz

    Hello. I'm implementing WebDAV COPY method.

    public void Copy(string userName, string password, string source, string destination)
    {
    CredentialCache MyCredentialCache = new CredentialCache();
    MyCredentialCache.Add(new System.Uri(source), "Basic", new NetworkCredential(userName, password));

            try
            {            
                HttpWebRequest Request = (System.Net.HttpWebRequest)HttpWebRequest.Create(source);
                Request.Credentials = MyCredentialCache;                
                Request.Method = "COPY";                
                Request.Headers.Add("Destination", destination);
                Request.Headers.Add("Overwrite", "F");               
                HttpWebResponse Response = (System.Net.HttpWebResponse)Request.GetResponse();         
                Response.Close();
    
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);                                         
            }
        }
    

    The method works fine with non-unicode file names. But, if I want to copy a file with korean letters in its name (http://myDAVserver.myCompany.com/dav/한글.txt) I get the following error:

    Message: Specified value has invalid Control characters.
    Parameter name: value

    I tracked the error, and the exception is being throwed exactly in

    Request.Headers.Add("Destination", destination);

    Does anybody have an idea how to handle this problem? Thank you.

    C# help csharp com tutorial question

  • try {} catch {} not working
    S ShadowUz

    Thanks for the answer. I will change "FileMode.OpenOrCreate" to "FileMode.Open" as you said. The oly problem that was causing the program crash was I was running it in debug mode. I have runned it by its own as BobJanova advised, and now it is working fine.

    C# question

  • try {} catch {} not working
    S ShadowUz

    Thanks a lot! I runned the app by its own as you told, and that worked!

    modified on Thursday, April 21, 2011 5:38 AM

    C# question

  • try {} catch {} not working
    S ShadowUz

    Hello! I want to know if file is being used by another process and wait until it's free. I'm using the following code:

    public static bool FileInUse(string path
    {
    bool blnReturn = false;
    FileInfo file = new FileInfo(path);
    System.IO.FileStream fs;
    try
    {
    fs = System.IO.File.Open(file.FullName, FileMode.OpenOrCreate, FileAccess.Read, FileShare.None);
    fs.Close();
    }
    catch
    {
    blnReturn = true;
    }
    return blnReturn;
    }
    )

    ; But, instead of returning a value, the programm is crashing in

    fs = System.IO.File.Open(file.FullName, FileMode.OpenOrCreate, FileAccess.Read, FileShare.None);

    What is wrong here?

    C# question

  • Main thread freezing while running a separate thread
    S ShadowUz

    Hello. I have a programm that scans the selected folder and adds all the files' names to the listbox. I'm running the scan function in a separate thread. But, still the main form is freezing. Here is my code:

    private void button2_Click(object sender, EventArgs e)

        {
            Thread mThread = new Thread(myThread);
            myThread.Start();
        }
    

    public void myThread()
    {
    AddFiles(label1.Text);
    }

    public void AddFiles(string targetDirectory)
    {

            if (listBox1.InvokeRequired)
            {
                AddFilesAdd method = new AddFilesAdd(AddFiles);
                listBox1.Invoke(method, new object\[\] { targetDirectory });
                return;
            }
    
            if (progressBar1.InvokeRequired)
            {
                AddFilesAdd method = new AddFilesAdd(AddFiles);
                progressBar1.Invoke(method, new object\[\] { targetDirectory });
                return;
            }
            string\[\] fileEntries = Directory.GetFiles(targetDirectory);
            foreach (string fileName in fileEntries)
            {
                this.listBox1.Items.Add(fileName);
                progCounter++;
                progressBar1.Value = progCounter;
                
            }
    
            // Recurse into subdirectories of this directory.
            string\[\] subdirectoryEntries = Directory.GetDirectories(targetDirectory);
            foreach (string subdirectory in subdirectoryEntries)
            {
                numberOfFolders++;
                AddFiles(subdirectory);
                
            }
    
    C#

  • Can't find any examples using the Microsoft WEBDAV API
    S ShadowUz

    Hello! I'm also looking for some example with DavAddConnection and etc. And still could not find anything at all. Did you success in wrapping WebDAV API? If so, could you, please, give me some references about that. Thank you. Shadow.

    C / C++ / MFC com json help tutorial

  • DavAddConnection example [modified]
    S ShadowUz

    Dear Andrew! Thanks for your help! I'm sorry for being pesky and dumb. I can connect to the server using browser with username and password. But, I'm not being able to do it using my app. Still I get the same error: "The network path you specified is not found.". :^)

    C / C++ / MFC sysadmin security cryptography help tutorial

  • Rename a folder?
    S ShadowUz

    Try

    MoveFile(LPCTSTR currentNameOfFolder,LPCTSTR newNameOfFolder);

    Example:

    MoveFile(_T("D:\\TestFolder\\RenameMe"),_T("D:\\TestFolder\\MyNewName"));

    C / C++ / MFC help question
  • Login

  • Don't have an account? Register

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