|
Are you compiling with the /unsafe target?
|
|
|
|
|
kevinnicol
I'm compiling it to a windows CE device. but even in visula studio the user controls are not visible
Chris
|
|
|
|
|
Hi all,
I've been looking for a way to write data to a CSV file based on a timer event, without success. Is there a standard .NET class that will do this?
Thanks.
|
|
|
|
|
There are timer classes and there are classes to perform file I/O. Were you expecting specialized support beyond this? If so, what kind?
/ravi
|
|
|
|
|
What I would like to do is write a variable value to a csv file dynamically at a certain interval (timer tick). Each tick would result in a new line in the csv file.
|
|
|
|
|
OK, that's fair.
One way to do this would be to open the file (for update) when your application starts, set up a timer to fire at a specific interval, and in the timer tick handler, write a line to the open file (and flush the file). When your program terminates (either normally or abnormally), close the file.
See the Timer and File classes for more information.
/ravi
|
|
|
|
|
This works, but it seems a bit flakey. Also, does anyone know how to limit the file size?
using (StreamWriter writer = new StreamWriter("C:\\log.csv", true))
{
writer.WriteLine(textBox1.Text + "," + System.DateTime.Now);
}
|
|
|
|
|
mprice214 wrote: This works, but it seems a bit flakey.
Define "flakey".
Remember, a Timer is only one way to go. You could also use a background thread. In this case, be sure to handle concurrent access of UI (and other) data.
/ravi
|
|
|
|
|
|
Luc Pattyn wrote: No problem[^].
Come again?
|
|
|
|
|
Luc is just having some fun at our expense.
/ravi
|
|
|
|
|
OT: I wished I lived in Belgium. It's a collector's haven for Dinky Toys.
/ravi
|
|
|
|
|
Ravi Bhavnani wrote: collector's haven for Dinky Toys
is it? I wasn't aware, I haven't seen one for ages.
I am a model railroad enthusiast myself (N gauge, i.e. scale 1:160).
|
|
|
|
|
Luc Pattyn wrote: I haven't seen one for ages.
You can relive some childhood memories here[^].
/ravi
|
|
|
|
|
Great.
The very first image[^] I looked at has a bill board for a shop in Ghent that is still there; I have bought some locs there once. Normally I go shopping in Germany...
PS: may I suggest you add some navigation to your catalogs, moving to the next/previous page would increase the
"user experience".
|
|
|
|
|
Sure, use System.Timers for your timer and System.IO for CSV file.
|
|
|
|
|
Sounds like you are doing some profiling/tracing. Google those terms, perhaps in combination with "C#" and anything more specific you are interested in. Or do as others say and create a timer that appends to the CSV file.
|
|
|
|
|
Hi boy,
try this.
using System;
using System.Windows.Forms;
using System.IO;
namespace WriteCSV
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
this.timer1.Enabled = !this.timer1.Enabled;
}
private void timer1_Tick(object sender, EventArgs e)
{
FileStream fs = new FileStream("test.csv", FileMode.Append, FileAccess.Write);
StreamWriter sw = new StreamWriter(fs);
sw.WriteLine(DateTime.Now.ToString());
sw.Close();
fs.Close();
}
}
}
|
|
|
|
|
Hello,
I'm developping a sync solution enables filtering but is there any way to load the changes form the source database into a dataset and mark the deleted or updated rows to transfer this dataset to client and update its data?
I've tryied to use the Microsoft Sync Framework but it does not allow filtering even if I use a custom provider because in my scenariro I want to sync a subset of the data on the server with a client and vice versa sync framework depends on primary key only which not acceptable here because when deleting or updating rows these rows may deletetd for another user in the source database the primary key in the client will not be the same as the server this is because I want to select the changes as xml and populate the dataset soit can mark the deleted rows and updated .. ctc
Dad
|
|
|
|
|
Normally in this situation there is a timestamp field, or some other type, in the database that is used to tell if a row has been updated. Add a where clause to your query to get the changed rows.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Yes I've done it but I want to transfer the data to the client as a dataset holding the changes so how I tell the dataset that certain row is deleted or inserted or updated when it reads the xml file and not aftr loading the data throw the rowstate property
Dad
|
|
|
|
|
I don't understand what you are asking. You have all the tools, what is the problem you are having?
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
I select the modified data from the sql server as a xml I've added an attribute to each row to tell me its state when I load this file to a dataset it does not read the stated it marks all rows as Added by default so if I want to change the state I have to loop over the table and change the rowstate property my question is Can I change the state when the data set loads the xml file or I have to loop over the table after population?
Dad
|
|
|
|
|
Why are you returning XML that is then placed into a dataset? This makes no sense at all. Its like converting an int to a string then back to an int.
Add the column to the select query then it will be in the dataset already. Otherwise, no, there is no other way except to iterate through the rows.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
I've tried the xml to let me choose an intermediate method to tell the dataset the state of rows but it will be more efficient if it loads the data directly but If it does, also, How can I tell the row state? this data set will be transferred to a client where another adapter will update the client database so the dataset must tell the state of the rows which I cant do when loading the data because the column which tell the state is invented by my sql script and it does not belong to table so the data set will trait it as a normal column.
Dad
|
|
|
|