This question already has an answer here:
How to detect a process start & end using c# in windows?
(1 answer)
Closed 8 years ago.
I am looking for a way to record when certain programs have been executed.
For instance, if Microsoft Word has been started I would like to write out a time and date stamp along with the program name.
The output I get. I may change it to an Excel spreadsheet. Just need a little guidance on where to look to capture user run programs.
It looks like you want to use the ManagementEventWatcher
example
msdn
As for creating an excel spreadsheet from data, you can easily find code for that.
like this
Related
This question already has answers here:
How can I create a “Open with” list as in Explore in my own application
(2 answers)
Closed 3 years ago.
I need to list all the PDF readers available in a given PC.
I've found many ways to get the default one, or to get just the adobe acrobat, but I need to be able to list them all like:
Adobe Acrobat
Foxit
...
Q: Can you list which program is associated with .pdf? A: Yes.
Q: Can you loop through all installed programs, and print out those which read .pdfs?
A: Yes ... but you need to make a list of "which programs read .pdfs". Windows doesn't know this a priori.
PS:
You should probably also include Chrome and Firefox (among others) in your list.
This question already has answers here:
Run interactive command line exe using c#
(3 answers)
Closed 6 years ago.
I can't seem to find a possible solution for entering 1 line of "command" into a CMD window. I searched the MSDN and asked google and they only found me solutions to enter text into a textfile, but that's not the same I guess.
Thank you in advance!
You're going to have to start the Minecraft service process from your .NET application. Whatever you've got now in the batch file you're using, you can duplicate that in the Process start code in C#, or you can just have your C# code run the batch file.
If you want a config file providing startup parameters, you could put that stuff in app.config and have your application give them to the Minecraft server process on startup.
Once you've got the process started, your application can keep the Process object and send repeated commands to its standard input stream, as outlined in this answer.
System.Diagnostics.Process.Start("CMD.exe", [your command]);
This question already has answers here:
Should log file streams be opened/closed on each write or kept open during a desktop application's lifetime?
(13 answers)
Closed 6 years ago.
i need to write data into a CSV file each 600 msec using a c# application . The question: is better open and close file each time or keep it open until the end of write data actions? Note: i will change file name each day and each 60000 record
Thanck a lot for your opinions
CSV files are really easy to write to. If you don't know how to write to a file, the dotnetperls is your friend. You can simply call BinaryWriter.Write() to write anything. Write a value then a comma. That's it! If this file is going to be edited by the user at the time of running the application, then don't keep it open. Otherwise, keeping it open makes sure nothing unexpected happens.
This question already has an answer here:
It is possible to read .Rdata file format from C or Fortran?
(1 answer)
Closed 6 years ago.
I have requirement to read data from ".RData" files and process them in C# application. I could not find any API which I can use in C#, I believe there is an API for F# which I don't use as of now because of learning curve in F#.
Could anybody please suggest code or API to read ".Rdata" files?
There's R.NET which would allow you to execute the load function, then get the saved variables from the environment, maybe? My guess is you'll need to run something like
engine.Evaluate("load('/my/data/dir/mydata.RData')");
var data = engine.GetSymbol("myvariablename");
This question already has answers here:
Notification when a file changes?
(3 answers)
Closed 8 years ago.
I have inherited application that, among many other things, has to watch if user writes/deletes text file into specific folder.
Currently, the application uses timer and polls after 5 seconds. I find this ineffective, and wish to improve this part of code.
My question is about existence of the .NET function that monitors changes in directory. Is there such function I can use to detect when a file is written/deleted in a specified folder?
Thank you.
Yes, you have the FileSystemWatcher class. It does exactly what you're looking for
Yes there is. I would suggest you take a look at the FileSystemWatcher class:
http://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher%28v=vs.110%29.aspx
It's quite easy to set up, and it monitors for Win32 events, so is relatively inexpensive to use.