|
|
You're welcome!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Member 11534552 wrote: and the server will read and accept instruction to capture a picture and save it into the server's file folder it self. Are you assuming that the server can take a picture using the clients webcam?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
The program is basicly a big search and replace tool and is a fantastic tool for removing spyware from programs like Firefox or Sware-iron and works by scanning all the files in a folder and sub folder to look for strings that have "http://" in them or look like a domain name and ends in "acb.com" or "abc.org"
The program flags up suspect links using a system of coloured flags and then offers the chance for the user to bulk replace the Url with a new value so long as the length of the replacement is the same length as the old one or else the machine code in the dlls/exe's would end up crashing
did you know that if you scanned the file system for a browser like Chrome that you would find about 20,000 urls within the folder ?
A Simple replace of "Google.com" for "Gxxgle.com" Soon stops the browser from calling home and I also give the same treatment to Microsoft code.
So whats wrong apart from me not having the time.
Well the program does not do a scan and indexes the sections within each file that contains a URL and needs to re-read each file (could be hundreds) each time a replacement is made which makes it slow since it only does a search and replace for one string at a time.
it could do with an index or something more simple like an array of text to be searched and replaces like.
Google.com,Gxxgle.com
Microsoft.com,SlowSoft.com
Youtube.com,OurTube.com
The program backs up the root folder before it runs because sometimes it will crash the program being "Fixed" because the strings being replaced are too short because i am lazzy and this would happen if you tried to fix google chrome by replacing "Google.com" and not using something more like "https://Google.com/SafeBrowsing"
I can play around because i wrote the program which work on all the major browsers i have come across so far after a few roll-backs due to the problems i have mentioned above but it needs to be made more fool proof so that anyone can use it as and when new versions of programs are released.
The program has resulted in my DNS server being full of bad DNS results 24/7 because programs like browsers are trying to call home two hundred times a day and thats just the way i like it.
Witten in c# and VS2010 if anyone would like to take it on then please drop me a line for the project.
|
|
|
|
|
|
I wouldn't really trust an application that claims to perform a search-and-replace in the binaries
Block them in the host-file or over the proxy.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I am supposed to create a C# solution to compare the data (table, column and row) from two different databases and update the 2nd one as follows:
1. with just the rows that are updated recently (incase of duplicates)
2. check for new/updated column in 1st one and update/delete in 2nd accordingly or drop the table entirely and copy it from 1st one.
3. check for new/updated table in 1st one and update/delete in 2nd accordingly or drop the table entirely and copy it from 1st one.
So basically I have to synchronize the data between the two databases.
As of now, I have just got to connecting the database part. I am not sure how to proceed (should I be dumping the data from the database and checking or is there a simpler way?).!!!
Any help would be appreciated.
Thank you!
|
|
|
|
|
|
Anyone knows how to handle timeout operation in task class in C#. I meant after a particular time of task progress , the current task should be disposed and another task with the same arguments should be started.
|
|
|
|
|
There's an excellent discussion about adding the ability to TimeoutAfter in this[^] article.
|
|
|
|
|
You could possibly use Timers, or if you meant the Exception then you should use try catch block. Share some more information about context please.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
Is there a good looking way of receiving an object reference instead of a new object with the linq extension methods? Id like the two code lines below to update the object within the salesLst.
ProdTotalSales ps = salesLst.First(p => p.Month == o.OrderDatum.Month);
ps.Antal += r.BestSaldo;
|
|
|
|
|
It does!
public class ProdTotalSales
{
public string Text { get; set; }
public int Value { get; set; }
public ProdTotalSales(string s, int i)
{
Text = s;
Value = i;
}
public override string ToString()
{
return string.Format("{0}:{1}", Value, Text);
}
}
ProdTotalSales p1 = new ProdTotalSales("P1", 1);
ProdTotalSales p2 = new ProdTotalSales("P2", 2);
List<ProdTotalSales> list = new List<ProdTotalSales>() { p1, p2 };
Console.WriteLine("Before:");
foreach (ProdTotalSales p in list) Console.WriteLine(p);
ProdTotalSales pn = list.First(p => p.Value == 2);
pn.Text = "P2 Modified";
Console.WriteLine("After:");
foreach (ProdTotalSales p in list) Console.WriteLine(p);
Before:
1:P1
2:P2
After:
1:P1
2:P2 Modified
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Well, I made the classic mistake of attaching too little code to my question, sorry about that. The thing is that my ProdTotalSales was declared as a struct. That meant that when I was debugging, the debugger showed ps.Antal=1 but salesLst[0].Antal=0 after executing the two rows of code above. I still dont understand how that could be. Now when I changed the ProdTotalSales into being a class, it works just fine. I would really appreciate an explanation to this. Could it have something to do with me calling the default-constructor?
The ProdTotalSales looked like this:
public struct ProdTotalSales
{
public int Year { get; set; }
public int Month { get; set; }
public int Antal { get; set; }
public ProdTotalSales(int _year, int _month, int _antal) : this()
{
Year = _year;
Month = _month;
Antal = _antal;
}
}
|
|
|
|
|
Ah! As you say, too little code!
The thing is that a struct is always a Value type, and a class a Reference type - which means that when you assign a struct instance to another variable you always get a copy, not a reference to the existing one - and it doesn't matter if you do it directly:
ProdTotalSales pn = list[0]
Or via a Linq method:
ProdTotalSales pn = list.First(p => p.Value == 2);
You always get a copy of the data, not a reference to the original item.
I wrote an article on the difference last year: Using struct and class - what's that all about?[^] which may help.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Yes, should have thought of that. I know the struct is a value typ, though didnt think of the implications of it. Thanks for the explanation, and Ill take a peek at your article.
|
|
|
|
|
TMattC wrote: didnt think of the implications of it.
You never do until it bites you!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
after looking at this MSDN: Struct[^]
is shows that struct is a value type hence how it behaves different to a class in this situation.
way around your issue I am not sure at the moment.
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
Hi!
I have made a c# program that writes a binary file of approximately 16 MB, then proceeds to process the file by reading and writing individual bytes after specific rules.
Generating the inital file runs without any issues, but when the actual processing starts, so do my problems:
Test application:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
FileStream Stream = new FileStream("test.file", FileMode.Create, FileAccess.ReadWrite, FileShare.None);
int i;
int NumReads, NumWrites;
NumReads = 0;
NumWrites = 0;
for (i = 0; i < 1024 * 1024; i++)
{
Stream.WriteByte(0);
NumWrites++;
}
while (true)
{
for (i = 0; i < Stream.Length; i++)
{
Stream.Position = i;
int x=Stream.ReadByte();
NumReads++;
if (i % 16 == 0)
{
Stream.Position = i + 8;
int y = Stream.ReadByte();
NumReads++;
Stream.Position = i + 10;
Stream.WriteByte(1);
NumWrites++;
}
}
Console.WriteLine("Loop done. Reads="+NumReads.ToString()+", Writes="+NumWrites.ToString());
ConsoleKeyInfo result = Console.ReadKey();
if (result.Key==ConsoleKey.Escape) break;
}
Stream.Close();
}
}
} The process is painfully slow, and the program appears to be reading huge amounts of data during the process, according to Task Manager, during program execution, it looks like the program is reading 300 MB/second, or more, which is about what my HDD can do. The number of writes performed are looking normal.
I have tried implementing counters for read and write operations, and these seem to match what I am trying to do.
I have tried lots of different buffer sizes when initializing the FileStream, but the results are the same.
I dont know whether it is Task Manager being off, or c# actually messing up I/O so badly.
Does anybody have any idea what is going on ?
Thanks in advance,
Dan
modified 2-Apr-15 1:15am.
|
|
|
|
|
Most of your code seems to be missing from that post. Use the "Edit" link to update the post with the missing code.
Also, you should wrap your code in <pre lang="cs"> ... </pre> tags, or use a fenced code block:
<pre lang="cs">
Your code goes here...
</pre>
-or-
```cs
Your code goes here...
```
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Sorry about that, and thanks for showing me how to do it properly, my post has been updated.
|
|
|
|
|
I think you forgot some code there. You may also want to use a code block for the code.
What do you get when you cross a joke with a rhetorical question?
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
Do questions with multiple question marks annoy you???
|
|
|
|
|
Sorry about the mess in the first post. I am new to the forum, and didnt know how to do it properly.
|
|
|
|
|
Reading and writing single bytes is hugely inefficient, especially when doing it randomly. Disk files are processed in fixed block sizes determined by the underlying filesystem. When you wish to write a random byte to a file the system must first read the block that contains that byte, replace the byte, write the block back to disk. So replacing a few bytes in a single disk block would incur quite a large overhead in the background.
|
|
|
|
|
Hi, Richard,
I agree, and since yesterday I have worked on implementing buffering, which is now operational.
But it seems that something far stranger is going on, as I tried a buffer that can hold the entire file in memory, and only write it at the very end. Still my number of reads explode when the program is running, and I have found out that the major part of the reads that Task manager is counting are done where my program does what calculations, and other stuff, none of which involve I/O at all....
Some of my method calls seem to generate I/O just by performing simple calculations, or filling an array with numbers, and such.
Still investigating what is going on.
|
|
|
|