|
many thanks!
I will look into system.threading.timer class first
Чесноков
|
|
|
|
|
Hi,
Below code will Help you
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.ServiceProcess;
using System.Text;
using System.Timers;
using System.IO;
namespace service
{
public partial class Service1 : ServiceBase
{
Timer t = new Timer();
StreamWriter writer = new StreamWriter("C:\\Service.txt");
public Service1()
{
InitializeComponent();
}
protected override void OnStart(string[] args)
{
t.Elapsed += new ElapsedEventHandler(t_Elapsed);
t.Interval = 60000;
t.Enabled = true;
writer.WriteLine("Service is Started");
writer.WriteLine("Timer has been started..");
writer.Flush();
}
void t_Elapsed(object sender, ElapsedEventArgs e)
{
writer.WriteLine(DateTime.Now.ToString());
writer.Flush();
}
protected override void OnStop()
{
t.Enabled = false ;
writer.WriteLine("Service is Stopped");
writer.Flush();
}
}
}
Thanks,
Sunil G.
|
|
|
|
|
Design view? For a Service? What?
What kind of Timer? I use a System.Timers.Timer
Did you start the Timer?
|
|
|
|
|
Hi,
I am trying to access outlook application in my c# code..I am able to read all mails when I debug..but when I try to access the same using a Windows service,I can't able to access..I get the following error..
"Retrieving the COM class factory for component with CLSID {0006F03A-0000-0000-C000-000000000046} failed due to the following error: 80080005."...Can anyone help me with this..
|
|
|
|
|
I'd guess it relates to permissions on the account the service runs under.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Hello ,
I am adding a header to excel using string builder as below.
StreamWriter stream = null;
try
{
string separator = " ";
int serialNumber = 1;
using (stream = new StreamWriter("c:/xyz.xls", false, Encoding.GetEncoding("Windows-1252")))
{
StringBuilder builder = new StringBuilder();
builder.AppendLine();
builder.Length = 0;
builder.Append("SerialNo.");
builder.Append(separator);
builder.Append("TimeOfValidity");
stream.WriteLine(builder.ToString());
}
}
Is theer any way I can make this bold?
Thanks
BV
|
|
|
|
|
This actually works ? Really ? Wow.
To make it bold you'd need to interact with Excel properly, and not by just appending your text to the file verbatim.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
HI
I wenet in through the article at :
http://www.dotnetspider.com/forum/ViewForum.aspx?ForumId=534[^]
and tried opening the excel application through
Excel.Application ExcelObj = new Excel.Application();
Excel.Workbook theWorkbook = ExcelObj.Workbooks.Open("C:/xyz.xls", 0, true, 5,"", "", true, Excel.XlPlatform.xlWindows, "\t", false, false,0, true);
I get the resharper error message showing "Cannot create an Instance ofthe interface "Excel.Application"
Also I can see issues for Open method and XLPlatform as it turns red
I have included in my reference COM object library named under COM tab - Microsoft Excel 12.0 Object Library.
Is there anything that I am doing wrong?
Regards
BV
|
|
|
|
|
Hi!
I'm looking for a format string (to String.Format()) which is capable of handling the following criterias:
My input is a real value like -0.00123456 or 1233456.134 etc.
I want the output in scientific representation like "-1.234560E-003".
I want the output string to ALWAYS be 14 chars long no matter what.
How does the correct format string to accomplish this look like?
I've tried "{0:E7}" for positive values and "{0:E6}" for negative values. But this doesn't cover values greater than 9.9999999E+999 and values less than 1.0E-999.
|
|
|
|
|
I suspect that means you need a great level of accuracy than C# offers. Are you using the floats, Decimals or doubles ? You may need a scientific library of some sort.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Well, the probability that I get values less than E-999 or greater than E+999 is more or less zero, but I thought that it would be cleaner if I could handle both positive and negative values with one format string.
I use doubles, but thats not carved in stone...
|
|
|
|
|
hi dudes,
i have a c# solution(windows application),when i want to deploy my project,it gathers all the application resources and needed files into one exe file named setup.exe,but the problem is that i dont want to install my application on the destination computer,i just want to run it quickly without installation,and the .net framework is already installed on the destination computer .how can i make one single exe file executable on the destination system?i dont have any problem if i have to seprate it from needed files like my access database.
i will be thankful if any of u guys can help me.
|
|
|
|
|
if it's .NET, you should be able to put it on a memory stick and run it from there.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
This is simply xcopy deployment. Just copy the files from your \bin\Release directory to a folder on the other machine, and voilà!
|
|
|
|
|
|
tnx for the replies dudes,now i have another problem,i have the single exe appllcation,but i only runs where the OS has dotnet framework 2.0,i want my application to run in any computer that has windows xp or vista.without no need to install dotnet framework.i will be thankfull if u have any idea.
|
|
|
|
|
Not possible. Kind of the whole point of a framework...
Me fail English? That's unpossible!
|
|
|
|
|
hello all
i have troubles with the following code
there are two forms
Form1 and Form2
Form1 is the owner of Form2
i need to move label1.text from Form2 to Form1 (note: both forms are running and visible)
here is my code
Form1 F1 = (Form1 )this.Owner;
F1.textbox1.text = label1.Text; // i had set textbox1 modifier property to public
thanks in advance
|
|
|
|
|
Mr.Kode wrote: Form1 F1 = (Form1 )this.Owner;
F1.textbox1.text = label1.Text; // i had set textbox1 modifier property to public
This should work, although it's probably the nastiest code I've seen today ( and that's huge ).
1 - why on earth can't anyone here give their variables meaningful names ? Form1 ? Label1 ? Are you all REALLY comfortable with that ?
2 - making your controls public is retarded. If you must, make a string property public that sets the text on the label, but don't expose the whole thing. If your doctor asks to see the back of your knee, do you take all your clothes off ?
3 - you say 'I have troubles' then you post code that looks like it should work. What troubles ? What's happening ? Does it run ? Does it blow up ? If you want to ask a question, you need to be CLEAR
4 - the best way to communicate between forms is delegates. Then no properties need to be exposed.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Christian Graus wrote: If your doctor asks to see the back of your knee, do you take all your clothes off ?
Depends on the doctor.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
Good call.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
thanks Christian ..
but i am still suffering
error null reference exception was unhandled
|
|
|
|
|
What line gives you the error ? Did you change your code completely to get rid of all the stuff I said was retarded and use delegates ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
F1.textbox1.text = label1.Text;
the exception fires on that line
i`ll try to delegate that ,but for now i need to solve the problem
|
|
|
|
|
Well, it would help if you knew what you were doing. I assume you have no idea what object is null ? Do you have any idea how to use the debugger ? Hit F9 with the focus on this line to set a breakpoint, hit F5 to debug and when the code stops on this line, you can hover over each object. Either F1 is null ( which seems unlikely as you cast it and don't use 'as' ), label1 is null ( unlikely as it's a local object ) or textbox1 is null. Once you work out which is null, you can work out why. Do you set the Owner of the form when you create it ? That may be the problem.
Mr.Kode wrote: but for now i need to solve the problem
Why ? This is surely not code that someone is going to use in real life ? It's a disaster, as I said.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|