CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 4 of 7 FirstFirst 1234567 LastLast
Results 46 to 60 of 91
  1. #46
    Join Date
    Dec 2009
    Posts
    109

    Re: Looking to develope skills

    Alright, I've kept the media player thing on hold for now because the DirectX SDK is 553 MB, which is kinda a big file to download at a 256kbps connection. :P
    And I've started a new project. A simple FileBackup program.
    I know what I'm supposed to do, and require a little assistance with a few things.
    First of all, how do I generate an event that will get activated when I click OK in a FolderDialogue?
    Second of all, "using System.???". What should be used if I want to work with FileHandling??

  2. #47
    Join Date
    Dec 2009
    Posts
    109

    Re: Looking to develope skills

    Somebody please answer my question.

  3. #48
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Looking to develope skills

    Quote Originally Posted by Dragster93 View Post
    First of all, how do I generate an event that will get activated when I click OK in a FolderDialogue?
    The easiest way is to open the form in the resource editor, select the button and then double click on it. This will create a click handler for you.

    Quote Originally Posted by Dragster93 View Post
    Second of all, "using System.???". What should be used if I want to work with FileHandling??
    What you need to do is learn how to use the Msdn free online library.

    Also, you need to learn how effectively search google. Asking questions on a forum like this is okay, but you can find the answer way faster yourself if you know how to search. For example search google for "How to open a file in .net C#", gives several hits. The first one, FileStream Open File [C#] looks promissing according to the description: "This example shows how to open files for reading or writing, how to load and save files using FileStream in C#."

    As a beginner what you need to do is actually try the code examples that you find on the internet. It's natural to want to try to stick the code snippet directly in your project, but I'd recommend that you create a separate test project, put the code snippet into it, debug it and get it running before moving the code into the real project.

    With regard to msdn, for file operations, check out the classes in the System.IO namespace.

  4. #49
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Looking to develope skills

    Quote Originally Posted by Dragster93 View Post
    Somebody please answer my question.
    Keep in mind that folks on this forum are volunteers. As such we aren't really required to answer any questions, and there definitely isn't any time limit if we decide to answer.

    If you are looking for a quick answer, the best thing I can tell you is to follow my advice in #48 and learn how to effectively use msdn and search in google. If you are able to do this, then you'll be able to find the answers to 99% of your questions on your own, and won't be bugged when someone doesn't respond fast enough.

  5. #50
    Join Date
    Dec 2009
    Posts
    109

    Re: Looking to develope skills

    Quote Originally Posted by Arjay View Post
    Keep in mind that folks on this forum are volunteers. As such we aren't really required to answer any questions, and there definitely isn't any time limit if we decide to answer.

    If you are looking for a quick answer, the best thing I can tell you is to follow my advice in #48 and learn how to effectively use msdn and search in google. If you are able to do this, then you'll be able to find the answers to 99% of your questions on your own, and won't be bugged when someone doesn't respond fast enough.
    Thanks for the tip dude!
    And I'm sorry but, I didn't mean to rush anyone into answering my question....I'm patient enough to wait for the answer....

    Actually, I did try searching on google but didn't get any help from there....the thing is that I couldn't find a way to generate an event for when the OK button in the FolderBrowserDialogue is clicked....

    But yes, what you said is correct....I shouldn't come around asking for help for every single problem that I have....

  6. #51
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Looking to develope skills

    Quote Originally Posted by Dragster93 View Post
    Thanks for the tip dude!
    And I'm sorry but, I didn't mean to rush anyone into answering my question....I'm patient enough to wait for the answer....

    Actually, I did try searching on google but didn't get any help from there....the thing is that I couldn't find a way to generate an event for when the OK button in the FolderBrowserDialogue is clicked....

    But yes, what you said is correct....I shouldn't come around asking for help for every single problem that I have....
    You don't need to intercept the OK button in the FolderBrowserDialog control. You just create an instance of it and call ShowDialog(). It won't return until the user presses the Ok or cancel button.

    To find out whether the user clicked OK, check the DialogResult enum value:

    Code:
    FolderBrowserDialog dlg = newFolderBrowserDialog( );
    
    if( DialogResult.OK == dlg.ShowDialog( ) )
    {
      string selectedPath = dlg.SelectedPath; 
    }


  7. #52
    Join Date
    Dec 2009
    Posts
    109

    Re: Looking to develope skills

    Arjay, thanks for the solution but i've already solved that problem by googling it. Now there's a problem that I can't seem to find a solution to.
    How do I copy an entire directory (along with all the files) to a specific loation (selected in the folder browser dialog)??

    Also, why am I not able to use the System.IO.Files or System.IO.DirectoryInfo namespaces???
    Shouldn't they be installed or copied during the installation??

  8. #53
    Join Date
    Dec 2009
    Posts
    109

    Re: Looking to develope skills

    Ok, the File BackUp Utility is ready!!
    And I would like someone to try it out and tell me how I can improve it.
    Also, I have a small doubt.
    Right now, if the Source is for eg: "d:\alarm" and the destination for eg: "d:\abhinav", the software copies only the contents of the folder 'alarm' to the destination. But what if I need the entire folder to be copied??
    Attached Files Attached Files

  9. #54
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Looking to develope skills

    A couple of small comments:
    1) With regard to code formatting, put in some white space between C# terms. It makes it easier to read with a bit of white space.
    2) There's no need to call ToString() on a string property.
    E.g. this,
    Code:
    txt_dest.Text=folderBrowserDialog2.SelectedPath.ToString();
    should be
    Code:
     
    txt_dest.Text = folderBrowserDialog2.SelectedPath;

  10. #55
    Join Date
    Dec 2009
    Posts
    109

    Re: Looking to develope skills

    Quote Originally Posted by Arjay View Post
    A couple of small comments:
    1) With regard to code formatting, put in some white space between C# terms. It makes it easier to read with a bit of white space.
    2) There's no need to call ToString() on a string property.
    E.g. this,
    Code:
    txt_dest.Text=folderBrowserDialog2.SelectedPath.ToString();
    should be
    Code:
     
    txt_dest.Text = folderBrowserDialog2.SelectedPath;
    Thanks for the comments dude!
    And thanks for that tip....will keep that in mind!
    So did you find a solution to my other question??

  11. #56
    Join Date
    Dec 2009
    Posts
    109

    Re: Looking to develope skills

    Awright, now that the File Backup program's finally complete (ofcourse, i will be doing more modifications to it slowly slowly!), I have started making an alarm program. I constructed the code, designed the UI and even debugged it. Well, its not totally debugged! The one problem that still remains is.....hold on, its better if you read my code first....

    namespace WindowsFormsApplication1
    {
    public partial class Form1 : Form
    {

    public Form1()
    {
    InitializeComponent();
    }

    //The funtion that handles the calculations of the alarm
    public static void SetAlarm(int hours, int minutes, int seconds)
    {
    string wav_loc = "c:\\testjazz.wav";
    SoundPlayer spWave;
    spWave = new SoundPlayer(wav_loc);

    DateTime dthours = new DateTime(hours);
    DateTime dtminutes = new DateTime(minutes);
    DateTime dtseconds = new DateTime(seconds);

    if (DateTime.Today.Hour == dthours.Hour && DateTime.Today.Minute == dtminutes.Minute && DateTime.Today.Second == dtseconds.Second)
    {
    spWave.Play();
    }
    else
    {
    return;
    }
    }

    //'Set Alarm' Button
    private void btn_alarm_Click(object sender, EventArgs e)
    {
    int hr;
    int min;
    int sec;
    hr = int.Parse(num_hour.Value.ToString());
    min = int.Parse(num_min.Value.ToString());
    sec = int.Parse(num_sec.Value.ToString());
    SetAlarm(hr, min, sec);
    }
    }
    }


    Everything's fine. The only problem is, whenever I click the 'Set Alarm' button (which calls "private void btn_alarm_Click(object sender, EventArgs e)"), whether the alarm time has arrived or not, the alarm starts to ring!

    Can someone please explain me what's wrong with my code.
    Thank You!

  12. #57
    Join Date
    Oct 2008
    Location
    Cologne, Germany
    Posts
    756

    Re: Looking to develope skills

    you're using the wrong DateTime constructor. you shold use the one that takes hours, minutes and seconds. currently it's taking ticks and I'm sure this is the buggy part.

    and please use the "code" tags in your posts. you're long enough here to know that.
    win7 x86, VS 2008 & 2010, C++/CLI, C#, .NET 3.5 & 4.0, VB.NET, VBA... WPF is comming

    remeber to give feedback you think my response deserves recognition? perhaps you may want to click the Rate this post link/button and add to my reputation

    private lessons are not an option so please don't ask for help in private, I won't replay

    if you use Opera and you'd like to have the tab-button functionality for the texteditor take a look at my Opera Tab-UserScirpt; and if you know how to stop firefox from jumping to the next control when you hit tab let me know

  13. #58
    Join Date
    Dec 2009
    Posts
    109

    Re: Looking to develope skills

    Quote Originally Posted by memeloo View Post
    you're using the wrong DateTime constructor. you shold use the one that takes hours, minutes and seconds. currently it's taking ticks and I'm sure this is the buggy part.
    Ohk. Thanks for clearing that doubt.
    Btw, which constructor should I be using instead?

    Quote Originally Posted by memeloo View Post
    and please use the "code" tags in your posts. you're long enough here to know that.
    Oops! :P
    My bad. Will remember that next time.

  14. #59
    Join Date
    Oct 2008
    Location
    Cologne, Germany
    Posts
    756

    Re: Looking to develope skills

    here's the list of all constructors. try to figure it out by yourself ;]
    http://msdn.microsoft.com/en-us/libr....datetime.aspx
    win7 x86, VS 2008 & 2010, C++/CLI, C#, .NET 3.5 & 4.0, VB.NET, VBA... WPF is comming

    remeber to give feedback you think my response deserves recognition? perhaps you may want to click the Rate this post link/button and add to my reputation

    private lessons are not an option so please don't ask for help in private, I won't replay

    if you use Opera and you'd like to have the tab-button functionality for the texteditor take a look at my Opera Tab-UserScirpt; and if you know how to stop firefox from jumping to the next control when you hit tab let me know

  15. #60
    Join Date
    Dec 2009
    Posts
    109

    Re: Looking to develope skills

    Quote Originally Posted by memeloo View Post
    here's the list of all constructors. try to figure it out by yourself ;]
    http://msdn.microsoft.com/en-us/libr....datetime.aspx
    Will do. Thanks!

Page 4 of 7 FirstFirst 1234567 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured