|
Ok. Thanks!
PS: Thank you again for the quick reply!
|
|
|
|
|
Console.Write/WriteLine writes to the Debug Output window. I don't know if it's possible to redirect this.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Console.Write writes to StdOut, which in the Visual Studio IDE is the debug window. In a console app, its the console window. You can mess around with setting the stdout but why bother when there are other methods available in a WinForms app.
only two letters away from being an asset
|
|
|
|
|
Hi,
Create a standard winforms project and then go to the project properties and change the output type to console. Magic, you'll have a console and a form.
Alan.
|
|
|
|
|
Hi,
I have internet connection to my desktop PC. I want to share internet from my desktop pc to Laptop using Bluetooth devices programatically.
Thanks,
Venky.
venki
|
|
|
|
|
|
hi all
i am currently using vs2005 c# window app , i am trying to make a crystal report base on the data i have in my ms sql database which i have binded programmically by using SqlConnection
thus i would like to know if i could use the same method to bind my database to the crystal report
so far i only done crystal report via data from a ms access database
is it possible? and any good keyword or hint for reference would be nice too
thanks
|
|
|
|
|
|
Can somebody please give me an example of a windows service that uses threading to look at a folder for files and if it finds a file then does some processing. Upon completion of processing looks again and continues... I don't know if it is wise to keep looking at a folder every second for files, please advice on that. If it is not then maybe put a wait and look every 20 minutes or so. Please help!!
I don't need code to look for files, etc. I just need some guidance on how to build the service with a thread.
Thank you in advance
Sameer
|
|
|
|
|
|
Hi again,
there is a FileSystemWatcher class that monitors changes to a folder or file; the problem with it (and with any other method of observation you could possibly come up with) is that it recognizes changes, rather than states, i.e. it will tell you a file got created, got written to, etc, but it is unable to signal a file has reached a new and consistent state (there is no FileClosed event or something similar).
The only really good way is for the file creator to signal you when a file create or update has been executed to completion.
I see no need to use threading, unless maybe if you want to watch several folders. You might want to tell us more about what the files are about, and what you intend to do to them.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Hi Luc,
As always thank you for your response. My windows service in short looks at 3 folders for .csv files, parses them and does some database updating. From time to time there are files added to these folders so I have to keep looking at a certain interval in these folders (currently configured every 20 minutes)
I decided to implement the following method:
http://en.csharp-online.net/Creating_a_.NET_Windows_Service%E2%80%94Alternative_1:_Use_a_Separate_Thread[^]
Please let me know if this is not a good method, I would hate to crash the server because that is where this service will be loaded
Thanks
Sameer
|
|
|
|
|
We do exactly the same thing except we use a winforms app to give feedback to the user, it chacks every 2 minutes and disables the timer while checking (otherwise eyou get multiple threads)
We have implemented a delay in the reading of the file to avoid touching files still being written by setting a flag with the time of first seeing the file, if more than # period has elapsed since seeing the file we can then process it.
This has been working perfectly for the past 4 years, at 2am it processes up to 1200 files an hour.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi,
one way to overcome the problem you don't get events when a file creation/update is completed is this, assuming you're in charge of the producer's code:
- look for "event files", recognized by a specific characteristic, maybe a new file extension .EVE
- create/update your data files in any way you see fit; when done, create a short .EVE file containing the full path of the data file. Such file will be written atomically since it fits in a single sector.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Ok, there are multiple way to do that. As Luc suggested you can use FileSystemWatcher Class to check a folder. If any new files created it will fire an event and based on that you can do the required operation.
you can use TimerDelegate with windows service to monitor on a specific duration.
Recentenly I have completed a similar application. Please let me know if you have more doubts. Hope I can help you in this.
Thank you.
|
|
|
|
|
|
Samir,
That is fine. I have one question regarding your application. How file are submitting into the Folder? Is it submitted by any client? Is there any possibilites the more than thousand files created on that folder?
|
|
|
|
|
Happy to hear that it is a good method. A different client creates and dumps these files. Usually, there is a single file at one point and what my application is doing is processing these files and dumping it to an Archive folder.
Sameer
|
|
|
|
|
I was asking because in my case there can be possiblity of many file submitted at the same time, because files are submitted via Web services. So I was wondaring with behaviour of FileSystemWatcher that it can manage that hughe change list or not. So what I did, I have stored the file name in DB while client storing the file into the folder, means my Web service save the posted file and store the Filename in DB . Now what I did, Windows Service read the DB load 100 Files name in DataSet, Process them one by one and update the dataset, After complete the all processing I have update DB with the updated dataset and Load the next 100 Records. Now If there is no records, I have used a DelegateTimer which will monitor the database with 15 min interval to file come. If file is there, I stopped the current timer and process those data.
|
|
|
|
|
what I am doing is reading the file names into a string array and then using foreach loop to process each file. This is incase there are multiple files. It seems to be doing a good job with the threading and the thread.sleep. I wonder if there are more system resources being used with my approach, I will monitor the error log and hopefully there won't be any issues
Sameer
|
|
|
|
|
|
I need to get the amount of computer physical memory.
Now, I can get the amount Windows uses by a GlobalMemoryStatus kernel32 API call.
However, this returns me the same number I see in the My Computer properties dialog box. And if I set MAXMEM paramter in the boot.ini file to 500M, this is what I'll get from this function.
Does there exist a way to find out how much memory's really plugged into my motherboard?
|
|
|
|
|
The WMI class, Win32_PhysicalMemory , will tell you how much memory is installed in each slot on the motherboard. Total it all up and you've got your total physical memory installed.
Google for "C# WMI System.Management" and you'll find examples on how to use WMI in your code.
Google for "Win32_PhysicalMemory" and you'll get the documentation on the class, including the properties to use to get your numbers.
|
|
|
|
|
That's great. Works fine for me. Thanks.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
thank you very much! works perfectly for me!
Just in case someone needs it, here's code:
using System;
using System.Management;
using System.Management.Instrumentation;
using System.Windows.Forms;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
ManagementObjectSearcher searcher =
new ManagementObjectSearcher("SELECT * FROM Win32_PhysicalMemory");
int banknumber = 1;
foreach (ManagementObject bank in searcher.Get())
{
MessageBox.Show("Bank " + banknumber.ToString() + " size = " + bank["Capacity"].ToString());
banknumber++;
}
}
}
}
modified on Tuesday, June 9, 2009 2:07 PM
|
|
|
|