|
Cheers.
I changed it to "NotifyFilters.FileName", as i am only interested in new files being created.
Regards,
Gareth.
(FKA gareth111)
|
|
|
|
|
Hi,
but filewatcher costs process overload.
why cant you try with API Hooking
you can track all the newly opened files and even you can block creating/edit/delete file activities.
unless i know the situation for what you are using filewatcher i cant suggest even hooking.
|
|
|
|
|
The app is going to be very small. All it does is watch a folder, if new files are created, alert the user and then the user runs something in the program.
At the moment it is using 11k of memory, so i dont think this is an issue. Its also an internal app, so i know what systems it will be run on, and they are fast.
Regards,
Gareth.
(FKA gareth111)
|
|
|
|
|
hi,
Ya fine ! you are correct,
i have given the situation where the file watcher is done for the entire system(all the logical and removable drives)
as you mentioned for watching one folder, it wont cost performance issues.
do proceed...!
|
|
|
|
|
hi guys,
I just came across a stupid "feature" of windows installer.
it can just create advertised shortcuts when installing your application which means, any file you delete for example gets "installed" again if you run your application by clicking on that advertised shortcut.
really wonder who gave their approval to crap like this ....but this is actually not my question.
first, I want to turn this "feature" off in my installation files. I learned this is not doable by visual studio 2008 itself, hence you have to download some sdk to do it? I havent figured out yet which steps are neccessary to do this.-.. is there an example out there how to do this?
and further and even more important, I need to change he advertised shortcut on existing installations into an non-advertised shortcut! -- is this doable and if yes, how? did somebody do this before?
thanks for suggestions
best regards
pirate
|
|
|
|
|
Piratenwichtl2000 wrote: I just came across a stupid "feature" of windows installer.
it can just create advertised shortcuts when installing your application which means, any file you delete for example gets "installed" again if you run your application by clicking on that advertised shortcut.
really wonder who gave their approval to crap like this
Actually, it's quite a useful feature when users screw up their applications for you. The next tiem they launch it, it repairs itself. It's also good for kicking off a process that needs to be run on a per-user basis, such as setting up a users profile for an application.
There is no way to turn this stuff off in the Setup and Deployment project in Visual Studio. You'ld have to use a third party MSI scripting tool, such as InnoSetup, Wise for Windows Installer, InstallShield, ..., to do this. Just take the shortcut out of the shortcuts table and add it back it as a file in the Files table. You'll, of course, have to make sure that the file ends up in the correct folder in the Directory table.
|
|
|
|
|
Hi Everyone, I am facing some kind of difficulty dealing with Microsoft Excel between version.
I am working on a program that open an excel file and write in it then close it.It works fine with excel 2007 version but giving me an exception with other version ( lower than 2007).
This is how I am creating the file.
Here my code:
Microsoft.Office.Interop.Excel.Workbooks workbooks = xl.Workbooks;<br />
Microsoft.Office.Interop.Excel.Workbook workbook = workbooks.Add(Microsoft.Office.Interop.Excel.XlWBATemplate.xlWBATWorksheet);<br />
workbook.SaveAs(System.Environment.GetEnvironmentVariable("AppData") + "\\TestFile.xls",Microsoft.Office.Interop.Excel.XlFileFormat.xlExcel8,<br />
Type.Missing,Type.Missing,Type.Missing,Type.Missing,Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlNoChange,Type.Missing,Type.Missing,<br />
Type.Missing,Type.Missing,Type.Missing);
Thanks in Advance for your help
Jashim
|
|
|
|
|
First, use the formatting tags when posting code, it makes it more readable.
What version of the interop assemblies are you using? I believe Office 2007 uses version 12. For Excel 2000 you may need an earlier version.
only two letters away from being an asset
|
|
|
|
|
Hi Mark Nischalke,
Thanks for your response. I am using the intero assemblies 12.0 as you said.
But how do I make compatible for both version at the same time. For example, I am installing this program one computer that has Excel 2002 another 2000 and 2007. So, what should I do to work with all version, if I want to.
Note: sorry for not using code properly because I am kind of new with codeproject. Don't know how to do it.
thanks again,
Jashim
|
|
|
|
|
jashimu wrote: sorry for not using code properly because I am kind of new with codeproject
You were close, instead of using the 'inline code' as you did, use the 'code block'.
|
|
|
|
|
I would suggest using late binding. I had faced similar issues while working with Excel. You can use Type.GetTypeFromProgId and Activator.CreateInstance methods to create excel object and then invoke the methods.
PS: Not sure about method names. No Visual Studio in this computer.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
Hi d@nish, I feel like I am not lucky because your computer doesn't have Visual Studio. Otherwise, I would ask you if you can be little more especific because I am not Expert yet. May be down the line I will not have to ask you details.
thanks for you respoonse.
Jashim
|
|
|
|
|
The code to get Excel through late binding is the following:
Type excelType = Type.GetTypeFromProgID("Excel.Application");
Excel.Application excelApp = Activator.CreateInstance(excelType) as Excel.Application;
Keep in mind that you could still get errors if you try to methods or parameters that are not available on older Excel versions.
|
|
|
|
|
bcp.exe blocked because some tables ware already involved in an other sqlTransaction
modified on Thursday, September 10, 2009 5:45 AM
|
|
|
|
|
Hello,
I have been working on a new project of a newtork game by this method:
http://www.codeproject.com/KB/game/eatergame.aspx
I have one server and one client. I am trying to add more than one client into the game but the server just ignores him. can someone explain me why?
|
|
|
|
|
Hi,
I guess the server is programmed for one remote client. Take a look at the server code to be sure. If you still have questions, you should ask the author of the article...
Regards
Sebastian
|
|
|
|
|
Hello,
I think you should check the code first, maybe there is some settings to control(Default settings), then you can modify them
April
Comm100 - Leading Live Chat Software Provider
modified 27-May-14 22:01pm.
|
|
|
|
|
Hi All,
I am looking to develop a program that will map a network from a machine based on the number of hops from the workstation. However I need a starting point.
Am i going to have to find some way of sending/injecting a packet or are there special classes that have been created to do this.
Any reference code or articles would be greatly appreciated.
Apologies for the broad post but we all need to start somewhere!
Regards,
Deviao
|
|
|
|
|
deviao wrote: Apologies for the broad post but we all need to start somewhere!
A better place would be here.
|
|
|
|
|
Hello,
I've created a function which walks pixel by pixel on an image, storing the pixel color on a Pixel Class.
The software was doing much processing on this loop because each time a new Pixel was found an instance of a Pixel Class was created. Then, I decided to declare a single Pixel Class instance outside the loop and then modify only its values inside the loop and then add it to the list of Pixel Class.
The problem started appearing after I did that. Now, when I try using BinarySearch on a List<t> it always returns me 0. It seems that C# is checking the Pixel Class instead of its content, which is what I want.
I tried to create an IComparer<t> to check the Pixel Class value but it doesn't work since the function always receive the same Class in both parameters, so the check is in vain.
So here I leave the question: How can I use BinarySearch on a class which only changes its content but not its address?
The (pseudo)code below illustrates the code before and after the changes:
BEFORE:
for (int x...)
for(int y...)
{
Pixel p = new Pixel();
p.value = ...
...
int pos = pixels.BinarySearch(p);
}
AFTER:
Pixel p = new Pixel();
PixelComparer pComp = new PixelComparer();
for (int x...)
for(int y...)
{
p.value = ...
...
int pos = pixels.BinarySearch(p);
int pos = pixels.BinarySearch(p, pComp);
}
public class PixelComparer : IComparer<Pixel>
{
public int Compare(Pixel a, Pixel b)
{
Console.WriteLine("{0} x {1}", a.value, b.value);
return a.value.CompareTo(b.value);
}
}
Thanks in advance,
|
|
|
|
|
Hi,
you can't store a lot of pixels in a single instance of Pixel; if you create only one Pixel, it will end up holding the data you inserted last. Storing a reference to the one Pixel over and over in some collection, does not help, all those references point to the same instance, so they all got changed to contain the same, last, value.
creating a new Pixel every time is too expensive as you discovered. So what you need to do is find a cheaper way for storing the data you want. I suggest an array of the simplest (value) type that can work for you, so either an array of int or an array of a little struct.
|
|
|
|
|
Hi Luc,
You are correct. I thought about that but my Pixel class contains two different fields:
1. Pixel color;
2. Number of hits (in order to track statistics of the color).
Since I sort the values in the end according to the number of hits I don't see an alternative but storing them together.
I've though about:
a. Changing the class to a structure to see if that speeds up the allocation time;
b. Using two different arrays but I think it will be hard to keep track of changes when they are rearranged.
c. Try to somehow retrieve the pallet of the image in beforehand and then compare it to the pixel color increasing only a hit vector where the hit position to be increased would be equivalent to the position of the pallet.
I think 'c' is the elegant solution but I don't know if it is the fast one. What do you think?
Regards,
|
|
|
|
|
OK, some comments:
1.
a general GDI+ image does not have a pallette, each pixel has ARGB values, typically 32-bit in total, and those can take any value. Your image source may be encoded by color index (e.g. 8-bit pallette) but AFAIK that is lost when the image gets loaded into an Image/Bitmap instance.
2.
with two arrays, their size would have to be the size (area) of the input image, that could be rather large. And you would have to implement your own sort algorithm to keep both arrays in sync.
3.
I would consider using a single Dictionary<Color,int> where the key is the pixel color and the value is the multiplicity. So the code to add a pixel would be: if already in dictionary increment value, else insert with value=1. Performing this on a megapixel image will be a slow operation!
BTW: make sure you allocate the dictionary with a well chosen initial capacity, I would pick image area divided by say 4 to avoid dictionary growth which would reallocate and copy all current data.
|
|
|
|
|
Hi Luc,
Reply to 1: Yes, I verified that just after I posted the reply.
Reply to 2: Agree.
Reply to 3: In fact, to use statistics I'd need a SortedDictionary since after I insert the values on this dictionary I need to sort them according to the number of hits. The problem here is that I verified that on SortedDictionary, as opposed to Dictionary, when you call Add method for an specific key, it does not update the value of the key, instead you have to remove the element using Remove and add it again using method. Therefore many search calls are done.
To illustrate:
if (color.ContainsKey(intColor))
{
int value = color[intColor] + 1;
color.Remove(intColor);
color.Add(intColor, value);
}
else
{
color.Add(intColor, 1);
}
Is there any other way to do that?
Regards,
|
|
|
|
|
|