I need to check when a specific application (that I known) access to a specific file (that I know)
In short I need to hook an external application to see when start to play a scecific wav file.
I like to track "before" or "during" but not "after" play the file.
To try to do it, I have imported this code on a console application:
Github Code
to do a test I have inserted this code;
var list = DetectOpenFiles.GetOpenFilesEnumerator(4780);
while (list.MoveNext())
Console.WriteLine(list.Current.FullName);
on main module where 4780 is the PID of a mediaplayer that play a wav file.
At debug (list.Current.FullName) I see only the file dependence but don't show me the wav file opened.
After show the first 2/3 debug lines the application crash (out of memory).
If I press F5 without debug the application crash (out of memory).
There is an easy to track when an external application play a specific wav file ?
Related
Is it possible to play a specific audio object in Wwise without having a separate event for it? I'm implementing a dialogue system, and I have thousands of audio clips for dialogues, and making an event for each and every one would be extremely time consuming and error prone and impossible to maintain.
So either play an audio object from a bank directly or somehow giving the event an argument as to which object to play (I know that goes against the idea of events and the fact that the caller shouldn't know exactly what clip is going to be played).
Use Wwise External Source plugin, described relatively well here. The docs on this feature are not the best, but the general workflow I used went something like this:
Stored voice over files outside the Wwise project and Unity streaming assets folder (could be anywhere, I used a folder next to the Assets folder)
Create a new Voice audio object in Wwise and add an External Source to it (edit the audio object, click "Add Source" and select External Source)
Wrote a simple python script to generate a .wsources XML file that reads all the files in the voice files folder
Add the .wsources file to the external sources in Project Settings in Wwise
Post the event from Unity with path being whatever you used as "Destination" in the .wsources file, ie. it's not an absolute path
My "app" is being hijacked by a monitoring service. After it dies, for some reason the app.config file is considered still in use, so I can't make changes.
The only thing I can do is rename the existing file, and save a new file with the old name.
This is not an interactive app, so I want to simply want to use notepad to make changes in the file between runs.
Here is what I would try:
Use Unlocker to figure out what service or process holds a handle to your file and "unlock" it
Try ProcessExplorer. In menu go to Find > Find handle or DLL, search for your .config file and figure out what process is "taking a lock" on the file
Once you figure out what's causing this, check if you can somehow add an exception for your file, so that it's not trying to open this config file - very unlikely but an AV process may do that. Other solutions is to kill a misbehaving 3rd party app and start it once you finished editing config file.
Double check that your app was actually killed and no longer runs. Use process explorer or default task manager (or any other similar tool on non-Windows OS).
I have a simple writing app for Windows 8.1, which I'm currently expanding to include tabs. I am also adding an autosave feature to these tabs, so that when the user 'closes' the app, it writes the content of the file and the path, if its an existing file, to a txt file in the localstorage.
This works great when the files are unsaved. The user closes the app, and after reopening all his tabs are there again, with the latest changes.
The problem I have is when the file is already saved. I store the path in the txt, so I thought I'd just open the file again on opening of the app, but the problem is that I am not allowed to open just any file on the system. The user could have opened a file from his C: drive, which I cannot read (for instance as described here).
Any ideas on how I could solve this. I'm afraid that what I'm trying to do will not be possible.
If needed I could show some code about saving the autosave file, but I didn't think I could show anything relevant to the question.
As Vasile said once the application closes you lose access to the StorageFile's that were outside the sandbox.
However WinRT does provide the StorageApplicationPermissions class where you can store those permissions to the file. You can then store the token for subsequent launches of the app.
It's cause the app is sandboxed and cannot access other storage areas than the Local Storage unless you involve user interaction via an Open picker.
Let's say you save the file on C:\. Also, save it on the Local Storage of the app. Next time, when the app is loaded, in the tabs will be shown the text file from the Local Storage - do your edits, save it somewhere in the PC and overwrite the file from the LocalStorage. In this way, the file you work with is actually the one in the local storage.
You have to be careful here with the namings. If you save SampleFile.txt on C:\ and then you create another one also called SampleFile.txt but on D:\, when you copy the file in the LocalStorage, it should be different from the first one. Here, you'll have to come up with yourown rules.
Sometimes my application throws an exception saying that the file is corrupted or unredable. Basically this file is a log file. My Application writes events and some data to the log file.
My Application was put on to Embedded box in which Windows XP OS runs.The only way to close the application is to shutoff power to the embeeded box. Since windows is not shutdown gracefully, the file is corrupted sometimes(this is what i am thinking).
I am using Intel SSD as a drive.I have enabled write caching on the disk. Does this cause the file corruption?
If i capture the exception, then can I delete this file using c# file functions(file.delete)?
Regards
Write caching doesn't cause file corruption. Shutting the machine off while the file is open causes the file corruption.
If you capture the exception then you should be able to delete the file.
You can probably lessen the frequency of errors if you call Flush on the log file whenever you write to it. You can almost completely eliminate the error if you close the file after every write (which, of course, would require that you open it for append before every write). That might be prohibitively expensive.
You can't completely eliminate the error as long as the only way to shut down the application is to remove power. You might consider rotating the log, though, so if it does get corrupted you only lose the last hour (or 15 minutes, or whatever amount of time you use for your log rotate frequency).
I have a C# winform application that accesses data from an MS Access database. This means my applications requires at least 2 files, the .exe file and the .accdb file. Is it possible to include the database in the .exe file, so my solution consists of a single file (the same way you would include an image in the project resources)? If it is possible, are they any major reasons why it shouldn't be done and how would you access the data from code? The project is a only a little one for personal use so if performance is hit it doesn't matter too much.
thanks in advance
It can be done. Simply add it to your project as you would add any other file (right click project -> Add -> Existing Item), then cancel all the dialogs that will popup offering you to handle it for you, then right click your database from your project explorer, go to properties and select Build Action: Embedded Resource.
Then use the method below to dump your database into a temporary file, which you can create by calling Path.GetTempFileName.
internal void CreateBlankDatabase(string destFile)
{
using (Stream source = new MemoryStream(Properties.Resources.MyEmbeddedDatabase))
using (Stream target = File.Open(destFile, FileMode.Truncate))
{
source.CopyTo(target);
}
}
(Note that MyEmbeddedDatabase would be your embedded database name). Then use your temporary file name in your connection string. Make sure you delete your temporary file after you're done. Also, as other said, you won't be able to modify and save any data.
No it shouldn't be done. How would you send someone and update to the .exe file without them losing their data? Keep it separate.
You need to have a way to manage how your applications installs and the file location in your connection string(s). There could be a \Data subfolder in your app folder with the .accdb file(s) in it.
You probably can't achieve what you want with an access database as an embedded resource, but you effectively get the same result by wrapping all your files in another executable app.
When you run the wrapper application, it extracts the "main" C# app, database file, and an updater app (more on this below) to the temporary files folder and runs the main app.
When the main app is closed, it runs the updater app, passing in the paths to the database file and original wrapper application. The updater app updates the wrapper application file with the changed database file. It then finally deletes the database main app and database file from the temp folder. Unfortunately, the updater app can't delete itself, but you could work around that by adding a command to the runonce section of the registry to delete the updater app on the next reboot.
Instead of figuring out how to extract and insert embedded resources, consider having the wrapper application as a compressed, self-extracting executable (like a self-extracting zip or rar file). Here's a codeproject article that describes how to turn a .Net app into a compressed, self extracting exe.
Access requires to be able to read and write to the file. The OS will lock the exe when it is run so that it can't be changed while in use. This along will cause it to not work, not to mention that Access simple wouldn't be able to read the exe as it is expecting a different file format.