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

Teuz

@Teuz
About
Posts
24
Topics
6
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • WebClient and Events
    T Teuz

    Thank you for the reply. How did you managed to make it work in a windows form project? This code acts exactly like the console one, no event are fired but the file is downloaded:

    using System;
    using System.Diagnostics;
    using System.Net;
    using System.Threading;
    using System.Windows.Forms;

    namespace WindowsFormsApplication1
    {
    public partial class Form1 : Form
    {
    public Form1()
    {
    InitializeComponent();
    }

        public void CheckUpdate(object arg)
        {
            // This simulates my update process
            DownloadFile();
            Thread.Sleep(5000);
            Debug.WriteLine("Update completed");
        }
    
        public void DownloadFile()
        {
            var webClient = new WebClient();
    
            var progressBar = new ProgressBar(); 
            AddControl(progressBar);
    
            webClient.DownloadProgressChanged += (o, e) =>
                                                     {
                                                         Debug.WriteLine(e.ProgressPercentage);
                                                         progressBar.Value = e.ProgressPercentage;
                                                     };
            webClient.DownloadFileCompleted += (o, e) => Debug.WriteLine("Download completed.");
    
            Debug.WriteLine("Starting download...");
            webClient.DownloadFileAsync(new Uri("http://cdimage.debian.org/debian-cd/5.0.4/i386/iso-cd/debian-504-i386-netinst.iso"), "debian-504-i386-netinst.iso");
        }
    
        private void button1\_Click(object sender, EventArgs e)
        {
            ThreadPool.QueueUserWorkItem(CheckUpdate);
        }
    
        private void AddControl(Control control)
        {
            if (flowLayoutPanel1.InvokeRequired)
                flowLayoutPanel1.BeginInvoke(new MethodInvoker(() => AddControl(control)));
            else
                flowLayoutPanel1.Controls.Add(control);
        }
    
    }
    

    }

    This is also quite similar the code I'm actually using in my project. I forgot to mention that for this project I'm using NET 2.0 so maybe this can work differently in later versions.

    C# help csharp linux debugging question

  • WebClient and Events
    T Teuz

    Ok Guys I'm facing a strange problem here, and I dunno if its a bug or I am doing something wrong. Here's the code:

    using System;
    using System.Diagnostics;
    using System.Net;
    using System.Windows.Forms;

    namespace ConsoleApplication
    {
    internal class Program
    {
    private static void Main(string[] args)
    {
    var webClient = new WebClient();

            //var progressBar = new ProgressBar(); 
    
            webClient.DownloadProgressChanged += (o, e) => Debug.WriteLine(e.ProgressPercentage);
            webClient.DownloadFileCompleted += (o, e) => Debug.WriteLine("Download completed.");
    
            Debug.WriteLine("Starting download...");
            webClient.DownloadFileAsync(new Uri("http://cdimage.debian.org/debian-cd/5.0.4/i386/iso-cd/debian-504-i386-netinst.iso"), "debian-504-i386-netinst.iso");
    
            Console.Read();
        }
    }
    

    }

    Everything works fine like this, events are raised normally. Now try to uncomment the progressbar initialization and events will stop to be fired (I noticed the problem with the progress bar because I needed to add a progress bar dynamically to the form, dunno if there are other scenarios where this happens) even if the download proceeds normally. Maybe is just me or maybe I have convinced myself this code is right that I cant no longer see where I epic fail. Anyone having the same problem? Thanks in advance. Matt

    C# help csharp linux debugging question

  • Date sting formatting, the easy way.
    T Teuz

    Epic! Especially the sb.Append('_');

    The Weird and The Wonderful ruby question career

  • Create Folder in FTP
    T Teuz

    Simply using the MKD command: http://en.wikipedia.org/wiki/List_of_FTP_commands[^] Hope it helps.

    C#

  • Controlling an injected DLL
    T Teuz

    Hi guys! I wonder if anyone can help me figure out a thing because I think my head will explode soon if I keep head butting my keyboard :D The problem is: I inject from C# a DLL (coded in C) into a process. The injected DLL hooks Winsock and give recv/send packets back to the controller (the C# program) through SendMessage/WM_COPYDATA. So far so good, it works flawlessy. Now I have the inverse problem. How can I give data back to the DLL? For example the controller receive a specific packet from the DLL and tells it how to act. I dont want to add too much things to the DLL but keeping it pretty simple/small and make the controller do the hard work. Hope I explained my problem enough :) Thank you all in advance.

    C# help tutorial question csharp

  • how can i send data by using connection of another program?
    T Teuz

    What about DLL injection?

    C# question

  • recieving error in this program
    T Teuz

    An array is 0 based. So if the array contains 500 elements the first has index 0 and the last 499. In your for cycle (with <=) at the end you were trying to access to the element with index 500 that obviously is outside the bounds of the array. http://msdn.microsoft.com/en-us/library/9b9dty7d(VS.80).aspx[^] :)

    C# database data-structures help

  • socket programing
    T Teuz

    Assuming there are no errors in the code, did you check the firewall?

    C# security beta-testing help question code-review

  • ATM program in consol application
    T Teuz

    If I undestood well: just create a variable, and increment it whenever the user fails to insert acc and pass. Once it reachs the times you set as limit (3) dont allow the user to log anymore. Hope this helps.

    C# security sales

  • database in sql server 2000 using c#
    T Teuz

    Just run the CREATE DATABASE query http://msdn.microsoft.com/en-us/library/ms176061.aspx[^] and then create your tables http://msdn.microsoft.com/en-us/library/ms174979.aspx[^] Hope this helps.

    C# database csharp sql-server sysadmin help

  • recieving error in this program
    T Teuz

    An array is 0 based, so 500 elements are indexed from 0 to 499. Just get rid of the = in the for cycles :)

    C# database data-structures help

  • C Pointers in C#
    T Teuz

    Thank you so much for your patience :)

    C# sqlite csharp tutorial question

  • text parsing or automatic segmentation of text in c#
    T Teuz

    You can parse or split text easily using regular expression. http://en.wikipedia.org/wiki/Regular_expression[^]

    C# csharp c++ json help tutorial

  • C Pointers in C#
    T Teuz

    I tryed to sort out the problem so I made this public partial class Form1 : Form { [DllImport("sqlite3.dll", EntryPoint = "sqlite3_libversion",CharSet=CharSet.Ansi)] private static extern string sqlite3_libversion(); [return: MarshalAs(UnmanagedType.LPStr)] public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { sqlite3_libversion(); } } Kept it simplier as possible. This should return a string with the version of sqlite. But this always gives the Accession Violation Exception. You can easily try this downloading the sqlite3.dll from the official site. Thank for you help :) I really appreciate.

    C# sqlite csharp tutorial question

  • C Pointers in C#
    T Teuz

    Thank you for your reply, unfortunately I had no luck with your tips. Googling I found a solution, even if it seems a workaround to me instead a properly solution. [DllImport("kernel32")] private extern static int lstrlen(IntPtr str); String PointerToString(IntPtr pointer) { Encoding enc = Encoding.UTF8; int pLen = 0; if (pointer == IntPtr.Zero) pLen = 0; else pLen = lstrlen(ptr); Byte[] bytes = new Byte[pLen]; Marshal.Copy(pointer, bytes, 0, pLen); return enc.GetString(bytes, 0, pLen); }

    C# sqlite csharp tutorial question

  • C Pointers in C#
    T Teuz

    Yep, but since I'm quite new to C# I would like to make one myself, for practicing in making wrappers for DLLs. My question is more about pointers to Char and strings than about SQLite. Btw Thank you, I'll check that asap :)

    C# sqlite csharp tutorial question

  • C Pointers in C#
    T Teuz

    Hi guys, I'm writing a SQLite wrapper but I'm having trouble handling pointers. Example: Original C function (from SQLite doc): const char *sqlite3_column_name(sqlite3_stmt*, int N); Import in C#: [DllImport("sqlite3.dll", EntryPoint = "sqlite3_column_name")] private static extern string sqlite3_column_name(IntPtr sqlite3_stmt, int N); This works, but sometimes (I dont understand why yet) it gives me back an Access Violation Exception. The same happens with this: const char *sqlite3_libversion(void); [DllImport("sqlite3.dll", EntryPoint = "sqlite3_libversion")] private static extern string sqlite3_libversion(); That always raise an Access Violation Excpetion. What I'm doing wrong? Thank everyone in advance. -MR

    C# sqlite csharp tutorial question

  • Display file and folders from computer in treeview with checkbox
    T Teuz

    You have to code a function that recursively scan a folder for files/folders and add it to the treeview. You can start with //this code shows a dialog to choose a folder FolderBrowserDialog FBD = new FolderBrowserDialog(); FBD.ShowDialog(); string path = FBD.SelectedPath; //with this you get files in the folder DirectoryInfo dirInfo = new DirectoryInfo(path); FileInfo[] filInfo; filInfo = dirInfo.GetFiles("*.*"); DirectoryInfo subDir = dirInfo.GetDirectory(); Or Something like this. Hope it helps.

    C# csharp asp-net data-structures help

  • Focus of listview on Vista
    T Teuz

    Hi guys, I'm trying to make the listview to look exactly like the one in Windows Explorer on Vista. I used the SetWindowTheme function from uxtheme to theme it, but I cant get rid of the focused border. I noticed that when the form that contains the listview lose focus there's no ugly dotted border. So is there any way to take away the focus from a single item in the listview? Thanks in advance Matteo

    C# question

  • Question about ListView
    T Teuz

    I'm trying that now, thanks alot for your quick answer.

    C# 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