building a reminder in winform [closed] - c#

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
I am a student and working on winform c#. I have a small app and I want to add a new feature of memo reminder. For example, when I type something in a text box, the app saves it and set a timer of 8 hours. If the app is running, then a message should popup with the message I have saved.
It's not clear to me if I should use a database for reminding the entries or something else provided by c#. As far as I know all thing are automated. Is there anything which will help me to build this functionality, like a timer??

Store somewhere in the txt file if using database is not possible.
Like this:
3.20.2013 11:20:00 | Remind me something.
Then your timer checks every minute or so.
UPDATE:
Example:
DateTime savedTime = Convert.ToDateTime("date from the text file");
if(DateTime.Now >= savedTime)
{
MessageBox.Show("reminder from the text file");
}
UPDATE2:
string pathToStoreTXT = Application.UserAppDataPath;
pathToStoreTXT has the path something like: "C:\Users\UserName\AppData". Your timer need's to check for that folder all the time. Name your txt file like "MyReminders.txt".

Simple flow would be:
When app is run, check if file is created or not. This file will store your data!
Check if there is any record in the file or not.
2a. Show expired messages and clear them too.
Add timer like Dilshod has suggested.
3a. Convert reminder datetime as timestamp and concatenate it with message to store in text file
Create at a timer object with tick event every 1 minute, something like this. (Obviously you will need to set frequency which is passed as parameter)

Related

can storing data in a database sometimes lead to corrupted data? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I have a field that's stored in the database as a string. It's actually a comma-separated string of numbers that I convert to a list of longs. The lines of code that do the conversion look somewhat like this:
TheListOfLongs = (from string s in StringFromDB.Split(',')
select Convert.ToInt64(s)).ToList<long>();
The code that creates the database storage string looks like this:
return String.Join(",", TheListOfLongs.Select(x=> x.ToString()).ToArray());
This works fine but as you can see, if for some reason there's a problem with the string, the code in the first line of code breaks on Convert.ToInt64(s).
Now I know I can wrap all this around a try statement but my question is this: can storing and retrieving a string in the database corrupt the string (in which case I definitely need the try statement) or is this a one a trillion odd type of event?
I wouldn't worry about corrupt data per se. However, you definitely need to handle the more general case where you can't parse what should be numeric data.
Even in the most controlled situations it is good programming practice to provide conditions for when you can't process data as you're expecting to be able to. What that means to your application is something you'll need to decide. Wrapping the statement with a try..catch will prevent your application from choking, but may not be appropriate if the parsed list is critical later on.
Selecting from the DB shouldn't corrupt your string.
If the connection is dropped mid transfer or something like that then an exception is thrown.

The fastest way to check number in txt file [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
H iguys. I have a loop which parse users id's and adds tham to txt file.
What's the best way than to check if this txt has this id skip it ( while next parsing ).
The size of txt rises from 5-..... mb
I tried to add ids to List, but when the size of file if bigger than 5mb the app begins hanging
Use a HashSet<int> or HashSet<string>, collect the ids in it, then at the end write the result to the text file.
PS: Note that HashSet is O(1) while List is O(n)
You should probably load all of the IDs in the text file into some collection and check if that collection contains the IDs.
I honestly don't think that there's a much more efficient way of doing it than that.
A rule of thumb I believe is to trade time with space. If you want to make copying faster and avoid looking into the file again and again then you may maintain an array or linked list or hash table which also have the id stored in it
var userIsAlreadyThere = File.ReadLines(path).Contains(userid);

Changing date-time format in c# [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
Creating digital clock. I'm newbie to C#. My code look like that
timeLbl.Text = DateTime.Now.ToLongTimeString();
dateLbl.Text = DateTime.Now.ToLongDateString();
Here is, the result
http://content.screencast.com/users/TT13/folders/Jing/media/da6d1f65-bf5f-4735-97dc-70485112a998/2012-07-02_1826.png
I got some questions:
Can I change time's format to 24 Hour? how?
How to change date into digits only format (like dd/mm/yyyy) or this result but in exact language (I mean, words "Monday, July" in another language, which windows support, for ex Turkish)?
How to make window dynamically change it's width (depending on text
length)?
Please help me,to achieve these 3 things. Thx in advance
Ans 1:
timeLbl.Text = DateTime.Now.ToString("HH:mm:ss");
Will convert time to 24 hour format.
Ans 2:
dateLbl.Text = DateTime.Now.ToString("dd/MM/yyyy");
Will convert date format to 31/06/2012
More formats here
The first and second point where been answered, for the last point set SizeToContent="WidthAndHeight" on the window and the window will dynamically resize based on its content size. I assume ur working with wpf, else it doesnt works!

How to create a folder in c# windows forms [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
How to create a folder automatically when a solution is installed in the computer i.e( Local Disk:D) using c# windows forms?
Solution#1:
On first run of the application (make an xml file to track the first execution) you may create folder.
Solution#2: (Good one)
You may check if that directory exists ,if not then create the directory
try
{
// If the directory doesn't exist, create it.
if (!Directory.Exists(palettesPath))
{
Directory.CreateDirectory(palettesPath);
}
}
catch (Exception)
{
// Fail silently
}
Source:
check this link
How to Add Items to a Deployment Project
http://msdn.microsoft.com/en-us/library/z11b431t.aspx
Specifically:
How to: Add and Remove Folders in the File System Editor
http://msdn.microsoft.com/en-us/library/x56s4w8x.aspx
See the MSDN for more info, but the gist is:
You set the path like either of the ways below. See string literals for more info on this:
string newPath = #"c:\yourpath";
or
string newPath = "c:\\yourpath\\morepath";
To create the directory, you use this:
System.IO.Directory.CreateDirectory(newPath);
Hope this helps!

How can I turn on my computer and immediately execute my program using C#? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
well i am developing a simple program (for me) it is for a note notes, you put a day and a time to your note, when it was the time and day, it appears a ballontip,
i have a problem here to, any time i put to this ballontip, it ever get to be only 5 seconds
DateTime hora; // hora == time
DataTable tabla = daonota.seleccionaraahora(); //chose now =seleccionar ahora
if (tabla.Rows.Count == 1)
{
hora = Convert.ToDateTime( tabla.Rows[0][4].ToString());
string titulo = tabla.Rows[0][1].ToString();
String texto = tabla.Rows[0][2].ToString();
texto=texto+"\Date programmed="+tabla.Rows[0][3].ToString();
texto = texto + "\nTime programmed=" + tabla.Rows[0][4].ToString();
notifyIcon1.ShowBalloonTip(10000, titulo, texto, ToolTipIcon.Info);
}
i have this code in a timer (timer1) it do a query every secund, do you know any form better for to do it (goal is it appears a ballon tip in the time put)
well i want to to ... if the computer is turn off, it turn on, any code for to do it since c#? and another thing... how do i do, my program is execute since the computer turn on, automatically?
I don't think I understood the whole question but still a few points:
You may want to look at the Windows Service type application. It will start before a User logs in.
"I [..] do a query every secund" : That's too fast for the balloon stuff. The noftification has it's own Timing and Queuing rules.
Well it's limited
Minimum and maximum timeout values are enforced by the operating system and are typically 10 and 30 seconds, respectively, however this can vary depending on the operating system. Timeout values that are too large or too small are adjusted to the appropriate minimum or maximum value. In addition, if the user does not appear to be using the computer (no keyboard or mouse events are occurring) then the system does not count this time towards the timeout.
Other limitations, background info: http://www.csharp411.com/notifyiconshowballoontip-issues/
Timeout Limits
Requires User Activity
One Balloon at a Time
Balloon Never Closes
Tip: To Close Balloons
To explicitly close a balloon at any time, simply set the NotifyIcon.Visible property to false, then immediately back to true.
You need to put a link to your program in the registry at:
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run
Then it will run every time the computer starts.
Add your program to your startup folder.
Your program need to be a Process. Search for "C# Process"

Categories