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??
Re: Looking to develope skills
Somebody please answer my question.
Re: Looking to develope skills
Quote:
Originally Posted by
Dragster93
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
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.
Re: Looking to develope skills
Quote:
Originally Posted by
Dragster93
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.
Re: Looking to develope skills
Quote:
Originally Posted by
Arjay
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.... :)
Re: Looking to develope skills
Quote:
Originally Posted by
Dragster93
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;
}
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??
1 Attachment(s)
Re: Looking to develope skills
Ok, the File BackUp Utility is ready!! :D
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??
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;
Re: Looking to develope skills
Quote:
Originally Posted by
Arjay
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?? :)
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! :)
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.
Re: Looking to develope skills
Quote:
Originally Posted by
memeloo
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
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. :)
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
Re: Looking to develope skills
Quote:
Originally Posted by
memeloo
Will do. Thanks! ;)