|
I guess you have to resort to using memory mapped files. And when an hour passes, you would have to move up the records except the first one (LIFO). Hope that helps.
|
|
|
|
|
I second log4net. Anything else is just asking for pain.
Cheers,
Vikram. (Proud to have finally cracked a CCC!)
|
|
|
|
|
In the unix world, there's a tool called logrotate, which basically loops over all your log files, removes the older lines, and backs them up in an archive - something like that would be relatively trivial to write in c#, and would keep the complexity out of your logging code. The only thing you'd have to be careful of, would be file lock clashes when both the logging tool and the rotate tool try to access the log at the same time
|
|
|
|
|
Thanks a lot,
I managed to toggle between two files as a logger as workaround. Still i am keen to explore the right and best way to implement this.
I'll post the solution as soon as i am done.
|
|
|
|
|
When you have the C# application compile an application. And Create an installer for it. Can C# Compact all the manafest files and resource file into the exe application file so that the application is self contained as 1 file instead of several files? Except for the xml or config file's?
|
|
|
|
|
Yes, but if you do that, some OSes will read the embedded one over a local one, and some will prefer the local one. It's safer to not have anything embedded.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
JollyMansArt wrote: the C# application compile an application
By "the C# application" I assume you mean Visual Studio?
JollyMansArt wrote: Create an installer for it.
A setup project?
JollyMansArt wrote: Can C# Compact all the manafest files and resource file...
Visual Studio can not compile everything into a single file, you need to use ILMerge[^] to do this.
only two letters away from being an asset
|
|
|
|
|
Hai,
I am currently doing my academic project in c# platform .net. I want to use a count down timer control in a particular page where I want to fill some articles before the specified time. I could easily work the timer,but I cannot enter any values into the textbox. If anyone knows please help me...
Thanks....
Sumi Koshy
|
|
|
|
|
textBox1.Text = "Hello World";
|
|
|
|
|
what values ?? Your message subject say you need help about Timer but you says
sumikoshy wrote: I could easily work the timer
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Please give me some pointers reg how to create event logs out of .EVT files. Also how can i possibly access the custome event logs on my m/c? I am tired of scouring the net finding out how to create an event log source PROGRAMATICALLY in C3 out of a .evt file.
rashu
|
|
|
|
|
I am currently using the following code to pull the usernames from the active directory:
One of my clients this code does not pull the windows login names in his active directory. Is there a better way to get this list? If so How? I need a complete list of the active directory users no matter the domain controler with in the domain that is hosting the user list.
public void WhatAreTheDomains()
{
try
{
DomainCollection domains = Forest.GetCurrentForest().Domains;
foreach (Domain domain in domains)
{
if (File.Exists(Environment.CurrentDirectory + "\\Debug.txt"))
{
MessageBox.Show("WhatAreTheDomains: " + domain.Name);
}
cboDomains.Items.Add(domain.Name);
}
}
catch
{
ErrorLogWriter("We have a problem communicating with the AD");
}
}
public void ShowDomainUsers()
{
string Path = "LDAP://" + cboDomains.Text + "/CN=Users,DC=" + Left(cboDomains.Text, (cboDomains.Text.IndexOf(".", 0))) + ",DC=" + Right(cboDomains.Text, (cboDomains.Text.Length - cboDomains.Text.IndexOf(".", 0) - 1));
string Filter = "(&(objectCategory=person)(objectClass=user))";
string[] PropertiesToLoad = new string[2] { "name", "sAMAccountName" };
try
{
if (File.Exists(Environment.CurrentDirectory + "\\Debug.txt"))
{
MessageBox.Show("ShowDomainUsers: LDAP://" + cboDomains.Text + "/CN=Users,DC=" + Left(cboDomains.Text, (cboDomains.Text.IndexOf(".", 0))) + ",DC=" + Right(cboDomains.Text, (cboDomains.Text.Length - cboDomains.Text.IndexOf(".", 0) - 1)));
}
using (DirectoryEntry domain = new DirectoryEntry("LDAP://" + cboDomains.Text + "/CN=Users,DC=" + Left(cboDomains.Text, (cboDomains.Text.IndexOf(".", 0))) + ",DC=" + Right(cboDomains.Text, (cboDomains.Text.Length - cboDomains.Text.IndexOf(".", 0) - 1))))
using (DirectorySearcher searcher = new DirectorySearcher(domain, Filter, PropertiesToLoad))
using (SearchResultCollection results = searcher.FindAll())
{
foreach (SearchResult result in results)
{
string name = (string)result.Properties["name"][0];
string winuserlogon = (string)result.Properties["sAMAccountName"][0];
DomainUsers = new DomainUsersClass();
DomainUsers.FullUserName = name;
DomainUsers.WindowsLogonName = winuserlogon;
DomainUsersArray.Add(DomainUsers);
}
}
for (i = 0; i < DomainUsersArray.Count; i++)
{
lbxDomainUsers.Items.Add(((DomainUsersClass)DomainUsersArray[i]).WindowsLogonName);
}
}
catch
{
MessageBox.Show("We are having a problem with the active directory.");
}
}
modified on Tuesday, August 18, 2009 5:43 PM
|
|
|
|
|
I figured out a way, which I just made the LDAP available to be modified on the fly which works, but I was hoping for a universal method of pulling users out of the active directory and into the listbox.
Overall I think I have the best way I know how. I was just wondering if there was a better way...
|
|
|
|
|
|
I've wrote a custom ToolStripMenuItem and its working good but when I select it, the PropertyGrid of VS 2005 never get refresh, it keep shows the previous selected object properties...I tried with a inbuilt control (NumericUpDown) and it does same thing. Any idea ?
here is test code
[ToolStripItemDesignerAvailability(ToolStripItemDesignerAvailability.All)]
public class NumericUpDownToolStipItem : ToolStripControlHost
{
public NumericUpDownToolStipItem()
: base(new NumericUpDown())
{
}
public NumericUpDown NumericUpDown
{
get { return (NumericUpDown)Control; }
}
protected override void OnSubscribeControlEvents(Control c)
{
base.OnSubscribeControlEvents(c);
}
protected override void OnUnsubscribeControlEvents(Control c)
{
base.OnUnsubscribeControlEvents(c);
}
}
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
m doin an applciation- file sending thru socket-
i think its send as bytes.but wht funcitoon i can use to send it.
do i need to save it to a temporary location to convert it to bytes
can any one help me
This code was posted by me...
|
|
|
|
|
send bytes in a specific format, like first of all send a long value that is the size of file and then keep send file's data in bytes...and at receiver-end first read that long value and write those bytes direct to file...
use Socket.Send() to send bytes...
Vivek Vijayan wrote: do i need to save it to a temporary location to convert it to bytes
no, .Net does itself...you can use either System.IO.File.ReadAllByte() if file size is smaller than 2GB or use FileStream
have a look at these
An Asynchronous Socket Server and Client[^]
File Transfer using Socket Application in C#.Net 2[^]
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
I believe the function is called: System.IO.File.GetAllBytes()
Or something like that.
Granted, if it's a big file, you probably want to stream it a chunk at a time, using an algorithm kind of like this:
byte[] buffer = new byte[BUFFER_SIZE];
StreamReader sr = ...open the file...
while (!sr.EndOfStream)
{
int numBytes = sr.Read(buffer, 0);
yourNetworkStreamWriter.Write(buffer, 0, numBytes);
}
|
|
|
|
|
Vivek Vijayan wrote: m doin an applciation- file sending thru socket-
i think its send as bytes
Yes. It will be send as several chunks of bytes.
Vivek Vijayan wrote: wht funcitoon i can use to send it.
Your message says you are just a beginner. So try with TcpListener and TcpClient classes. However, the best way to do network programming is to work with Socket class directly.
Vivek Vijayan wrote: do i need to save it to a temporary location to convert it to bytes
File.ReadAllBytes[^] will give you bytes of a file.
I'd suggest to please avoid txtspeak[^] when you post messages. It is not readable.
|
|
|
|
|
Vivek Vijayan wrote: do i need to save it to a temporary location to convert it to bytes
Huh?! A file is already made of bytes. What conversion are you talking about?
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Hi , have a good day
I have a DataTable with two columns
and it's rows are something like this :
<br />
--------<br />
PC1|AP1|<br />
--------<br />
AP2|AP1|<br />
--------<br />
RP1|PC4|<br />
--------<br />
AP2|PC4|<br />
--------
So , If I want to tell the path From PC1 to PC4 it would be like this :
PC1-->AP1-->AP2-->PC4
How I can tell that by Code ?
any help would be very appreciated !
even if you don't have a full answer , please just say your word.
A drowning man will clutch at a straw
Kind regards ....
I know nothing , I know nothing ...
|
|
|
|
|
You have to use a path finding algorithm. First you should define a structure which can describe your data set. The data structure for these kind of problems is usually a tree, but you should describe your problem more in detail. Are the connections one-way or two-way ?
Path finding can then be achieved by using a function to walk the data structure, starting from the source node (PC1) and visiting all of its children, and their children recursively, until the destination (PC4) node is found or you run out of children nodes.
If your connections are not one-way, then you must also flag the visited nodes in order to avoid infinite loops.
2+2=5 for very large amounts of 2
(always loved that one hehe!)
|
|
|
|
|
"Padding is invalid and cannot be removed" - this is the error message I am getting when trying to decrypt a file.
I have an application which will encrypt a file and then copy the file to a network location. (No Problems)
The application can also 'download' the file and decrypt it - This is done by copying the file locally (with .tmp appended to the filename) and then decrypted to another file (so you basically end up with encrypted and decrypted files when you 'download').
If I upload a file, then I can download without problems. But I cannot download a file that another user has uploaded. Now, as I said you get two files when you download. If I use a testing application (which has exactly the same decryption code) then I can successfully decrypt the temporary file that was created during the 'download'
I cannot see the logic here at all. Please see my two methods below for encryption/decryption...
public static bool EncryptFile(string inputFile, string outputFile)
{
PasswordDeriveBytes pdb = new PasswordDeriveBytes(fileEncryptionPassword, new System.Security.Cryptography.SHA384Managed().ComputeHash(new System.Text.UnicodeEncoding().GetBytes(fileEncryptionPassword)));
byte[] key = pdb.GetBytes(32);
byte[] IV = pdb.GetBytes(16);
RijndaelManaged rm = new RijndaelManaged();
rm.Key = key;
rm.IV = IV;
rm.BlockSize = 128;
rm.Padding = PaddingMode.PKCS7;
FileStream fsIn = new FileStream(inputFile, FileMode.Open, FileAccess.Read);
FileStream fsOut = new FileStream(outputFile, FileMode.Create, FileAccess.Write);
bool success = true;
try{
CryptoStream cs = new CryptoStream(fsOut, rm.CreateEncryptor(), CryptoStreamMode.Write);
int bytesToWrite = 0;
byte[] buffer = new byte[4096];
while(true)
{
bytesToWrite = fsIn.Read(buffer, 0, buffer.Length);
if(bytesToWrite == 0)
break;
cs.Write(buffer, 0, bytesToWrite);
}
cs.Close();
}
catch
{
success = false;
}
fsIn.Close();
fsOut.Close();
if(!success)
File.Delete(outputFile);
return success;
}
public static bool DecryptFile(string inputFile, string outputFile)
{
PasswordDeriveBytes pdb = new PasswordDeriveBytes(fileEncryptionPassword, new System.Security.Cryptography.SHA384Managed().ComputeHash(new System.Text.UnicodeEncoding().GetBytes(fileEncryptionPassword)));
byte[] key = pdb.GetBytes(32);
byte[] IV = pdb.GetBytes(16);
RijndaelManaged rm = new RijndaelManaged();
rm.Key = key;
rm.IV = IV;
rm.BlockSize = 128;
rm.Padding = PaddingMode.PKCS7;
FileStream fsIn = new FileStream(inputFile, FileMode.Open, FileAccess.Read);
FileStream fsOut = new FileStream(outputFile, FileMode.Create, FileAccess.Write);
bool success = true;
CryptoStream cs = new CryptoStream(fsIn, rm.CreateDecryptor(), CryptoStreamMode.Read);
try{
int bytesToWrite = 0;
byte[] buffer = new byte[4096];
while(true)
{
bytesToWrite = cs.Read(buffer, 0, buffer.Length);
if(bytesToWrite == 0)
break;
fsOut.Write(buffer, 0, bytesToWrite);
}
}
catch(Exception ex)
{
Debug.Show(ex.Message + "\n\n" + ex.StackTrace + "\n\n" + ex.InnerException.Message);
success = false;
}
finally{
cs.Close();
}
fsIn.Close();
fsOut.Close();
if(!success)
File.Delete(outputFile);
return success;
}
Sorry for so much code, but I'm sure it will be useful.
The decryption method is called directly after the code that copies the file from the network to a local folder, this is done using File.Copy() with the overwrite property set to true.
Thanks for any help
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
This[^] may explain - make sure you read the response from Tarik Soulami [MS].
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)
|
|
|
|
|
Interesting a bug in .NET Framework.
Life is a stage and we are all actors!
|
|
|
|