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??
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.
Originally Posted by Dragster93
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.
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.
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....
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:
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??
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??
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,
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,
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);
//'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!
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
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?
Originally Posted by memeloo
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
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.