|
|
You're welcome!
Best,
John
-- LogWizard Meet the Log Viewer that makes monitoring log files a joy!
|
|
|
|
|
Because you will have a copy of the list, but the elements themselves still point to your internal list - and they can still change as you access them.
Then every time I want to access the hostAddresses list I should use a getter instead of storing it in a a tmp variable like I have above, isn't it? because modifying (adding/removing items from) the hostList is protected with a lock inside say Add function, and if someone modifies it between two executions of getters, that is fine, I can't control that, but if I used tmp variable - then each time it would show old values
|
|
|
|
|
If SocketStructure is a struct or an immutable class , then you might want to consider using the immutable collections[^] from NuGet[^].
That way, any modifications to the collection will create a new collection instance, and replace the existing field. Any threads which have already retrieved a version of the collection will not see the changes unless they retrieve it again.
The immutable collections were designed to minimize the cost of creating a new version of the collection for every change.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I want to write a class named as "Fingerprints" that upload, update and delete the fingerprints of source codes or other format files in desktop application of c# language.
|
|
|
|
|
thats good - whats your specific problem ? since you dont show any code, we cant really help you with it
|
|
|
|
|
I suggested in my response to your original question that you need to add some proper details to your question. For example, what do you mean by fingerprints of source codes or other format files? And where do you plan to 'upload' these files or fingerprints to?
|
|
|
|
|
I assume that what you are looking to do is to track the unique identities of files so you are wanting to look at things like the file path, the size of the file and a hash of the file contents - at a high level, this is the fingerprint of the file. Then you want to save this information somewhere, so you want to perform the CRUD operations on this information. Is this correct?
|
|
|
|
|
yeah you're true this is small part of my project
my actual project is develop a system for plagiarism detection
|
|
|
|
|
So, you're using this to track files that you've already tested for plagiarism, and not using this as part of the plagiarism detection itself? Basically, you're going to need to build a database of these files that consists of the path, the file length and the hash of the file. The logic works something like this:
- If the path does not exist in the database, you know you're going to need to check it.
- If the path does exist, compare the actual file length against the one you stored in the database. If it differs, you're going to need to check it.
- Assuming you've reached this point, you're going to have to hash the physical file and then compare it against the hash you've stored. Again, if it differs, you're going to need to check the file.
Now, what I would do if I were writing this is assign a Guid at the start of your processing - then when you add a record, or find the record in the database, you'll update it with this Guid. Once you've gone through all your files, the files that are present on your machine will be marked with this Guid in the database. Any files that have been renamed or deleted on the disk will not have this Guid associated, so you can get rid of them from your database.
|
|
|
|
|
|
|
this is small part of my project
my actual project is develop a system for plagiarism detection
|
|
|
|
|
Error Details: No mapping exists from object type System.Web.UI.WebControls.TextBox to a known managed provider native type
Following are the code
protected void btn_save_Click(object sender, EventArgs e)
{
conn.Open();
SqlCommand cmd = new SqlCommand("insert into tbl_reg(name, f_name, m_name, dob, gender, phone, address, class, roll_no, section, user_nm, pswd)", conn);
cmd.Parameters.AddWithValue("@name", txt_nm.Text);
cmd.Parameters.AddWithValue("@f_name", txt_f_nm.Text);
cmd.Parameters.AddWithValue("@m_name", txt_m_nm.Text);
cmd.Parameters.AddWithValue("@dob", txt_dob);
if (rbtn_m.Checked == true)
{
cmd.Parameters.AddWithValue("@gender", rbtn_m.Text);
}
else
{
cmd.Parameters.AddWithValue("@gender", rbtn_f.Text);
}
cmd.Parameters.AddWithValue("@phone", txt_phone.Text);
cmd.Parameters.AddWithValue("@address", txt_address.Text);
cmd.Parameters.AddWithValue("@class", drpdn_class.SelectedValue);
cmd.Parameters.AddWithValue("@roll_no", txt_rollno.Text);
cmd.Parameters.AddWithValue("@section", txt_section.Text);
cmd.Parameters.AddWithValue("@User_nm", txt_user_nm.Text);
cmd.Parameters.AddWithValue("@pswd", txt_pswd.Text);
cmd.ExecuteNonQuery();
conn.Close();
}
|
|
|
|
|
Just a guess, but change this:
cmd.Parameters.AddWithValue("@dob", txt_dob); To this:
cmd.Parameters.AddWithValue("@dob", txt_dob.Text);
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Thank u so much, its helpfull.
Could u plz give me proper code flow if possible, I'll be thankful.
|
|
|
|
|
Your query is missing the VALUES clause, so the next error you'll get is a SQL syntax error.
INSERT INTO tbl_reg (name, f_name, m_name, dob, gender, phone, address, class, roll_no, section, user_nm, pswd)
VALUES (@name, @f_name, @m_name, @dob, @gender, @phone, @address, @class, @roll_no, @section, @user_nm, @pswd)
You should wrap your connection and command objects in using blocks to ensure that they are properly disposed of when no longer needed.
You're storing the connection as a class-level field, which is a bad idea. It should be a local variable, created as late as possible, and disposed of as soon as possible.
private static SqlConnection CreateConnection()
{
string connectionString = WebConfigurationManager.ConnectionStrings["YourConnectionString"].ConnectionString;
return new SqlConnection(connectionString);
}
...
using (SqlConnection connection = CreateConnection())
using (SqlCommand command = new SqlCommand("...", connection))
{
...
}
You seem to be storing passwords in plain text, which is a very bad idea. You should only ever store a salted hash of the user's password:
Secure Password Authentication Explained Simply[^]
Salted Password Hashing - Doing it Right[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hi,
I have a form in which i have some functionalities in form_keyup event.
This event is not getting triggered if the key has been released when the message box has been displayed.
|
|
|
|
|
There's a problem with your code.
Since we can't see your code, we can't tell you what the problem is.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
|
What key actions do you want to intercept when a MessageBox is showing: only a few, perhaps like the Enter Key being pressed ... or, all key events ?
We need to know what you are doing now in code to get the Key up/down or press/release event. Show us the relevant code (but, not all your code !).
Is the Form in which you want to monitor keystrokes the Main Form of a WinForm Application ?
If you are using a MessageBox in WinForms, it is displayed modal, and it blocks the UI thread, so key events are not routed to the Form/Context that showed it.
It is not standard practice to allow key-entry in a MessageBox except for system-defined keys that have certain standard side-effects (like press 'Enter and you get the default MessageBoxButton 'clicked).
Depending on the information you provide, there may be several choices including using another Form, or a UserControl, shown modal, or more complex technique involving P/Invoke to WinAPI calls, or setting an Application Key Global Hook.
«I want to stay as close to the edge as I can without going over. Out on the edge you see all kinds of things you can't see from the center» Kurt Vonnegut.
modified 2-Nov-15 10:41am.
|
|
|
|
|
This is my code. what should i do if i want to make word in table center.
protected void ButtonCreatePDF_Click(object sender, EventArgs e)
{
var doc = new Document(PageSize.A4);
doc.SetPageSize(iTextSharp.text.PageSize.A4.Rotate());
var output = new MemoryStream();
var writer = PdfWriter.GetInstance(doc, output);
doc.Open();
var titleFont = FontFactory.GetFont("Algerian", 35 );
var actionFont = FontFactory.GetFont("Comic Sans MS", 15);
var recipientFont = FontFactory.GetFont("Lucida Calligraphy", 25);
var reasonFont = FontFactory.GetFont("Comic Sans MS", 15);
var dateFont = FontFactory.GetFont("Lucida Calligraphy", 25);
var certDetailTable = new PdfPTable(1);
certDetailTable.HorizontalAlignment = Element.ALIGN_MIDDLE;
certDetailTable.SpacingAfter = 0;
certDetailTable.SpacingBefore = 0;
certDetailTable.DefaultCell.Border = 0;
certDetailTable.AddCell(new Phrase(TextBoxTITLE.Text, titleFont));
certDetailTable.AddCell(new Phrase(TextBoxACTION.Text, actionFont));
certDetailTable.AddCell(new Phrase(TextBoxRECIPIENT.Text, recipientFont));
certDetailTable.AddCell(new Phrase(TextBoxREASON.Text, reasonFont));
certDetailTable.AddCell(new Phrase(TextBoxDATE.Text, dateFont));
doc.Add(certDetailTable);
doc.Close();
Response.ContentType = "application/pdf";
Response.BinaryWrite(output.ToArray());
}
|
|
|
|
|
You need to create the Cell, set its horizontal alignment property to ALIGN_CENTER, then add the Cell; see: [^], [^].
There's a free book on ITextSharp available: [^].
«I want to stay as close to the edge as I can without going over. Out on the edge you see all kinds of things you can't see from the center» Kurt Vonnegut.
|
|
|
|
|
CERTIFICATE OF ARCHIVEMENT
Presented To
Recipient Name
For Outstanding Archivement
Day/Month/Year
now, my pdf document contain all above word. the location of word is at left page. but i want to make those word located at the center of document.
|
|
|
|
|
Hi,
I want to download a csv file in a button click and send back to the control to another page. I have a page a.aspx where i need to download the csv. Once i download the csv the b.aspx should be loaded. i am getting an exception cannot redirect after http headers have been sent
My code is
ponse.ClearContent();
Response.ContentType = "application/text";
Response.AddHeader("Content-Disposition", "attachment; filename=" + filename);
Response.Charset = "";
string sep = "";
for (int i = 0; i <= dtsorted.Columns.Count - 1; i++)
{
Response.Write(sep + dtsorted.Columns[i].ColumnName + ',');
}
Response.Write("\r\n");
for (int i = 0; i < dtsorted.Rows.Count; i++)
{
sep = "";
for (int j = 0; j <= dtsorted.Columns.Count - 1; j++)
{
Response.Write(sep + dtsorted.Rows[i].ItemArray[j].ToString() + ',');
}
Response.Write("\r\n");
}
Response.SuppressContent = true;
Response.Redirect("VerifyLPODetails.aspx", true);
if (!Response.IsRequestBeingRedirected)
{
Response.Redirect("VerifyLPODetails.aspx", true);
}
|
|
|
|
|