|
Some remarks for your code.
1. Use Image class directly instead of Bitmap. And don't use Jpeg format use MemoryBmp, it will ease byte comparing.
bild.Image.Save(ms1, System.Drawing.Imaging.ImageFormat.MemoryBmp);
2. Don't use
if(byteArray1 == byteArray2)
coz you are doing the same wrong thing again. I told you to compare byte by byte using looping like as follows
if(byteArray1.Length == byteArray2.Length)
{
for(int i = 0; i < byteArray1.Length; i++)
{
if(byteArray1[i] != byteArray2[i])
return false;
}
return true;
}
return false;
Hope this will give you the desired result.
|
|
|
|
|
We tried that but,
bild.Image.Save(ms1, System.Drawing.Imaging.ImageFormat.MemoryBmp);
Returns an ArgumentNullException. "Value cannot be null, parameter name: encoder".
I guess the MemoryBmp ImageFormat is null or something.
Didn't you get this exception?
|
|
|
|
|
Use System.Drawing.Imaging.ImageFormat.Bmp instead. Here is the test code
Image img1 = pictureBox1.Image;
Image img2 = pictureBox2.Image;
MemoryStream ms1 = new MemoryStream(), ms2 = new MemoryStream();
img1.Save(ms1, ImageFormat.Bmp);
img2.Save(ms2, ImageFormat.Bmp);
byte[] byteArray1, byteArray2;
byteArray1 = ms1.ToArray();
byteArray2 = ms2.ToArray();
if (byteArray1.Length == byteArray2.Length)
{
for (int i = 0; i < byteArray1.Length; i++)
{
if(byteArray1[i] != byteArray2[i])
MessageBox.Show("Not Same");
}
MessageBox.Show("Image Same");
}
else
MessageBox.Show("Not Same");
Inform me if it solves the problem.
|
|
|
|
|
It didn't work, but I will find another way to do it.
Thank you for all your help.
|
|
|
|
|
Try this one!!
it works for me!
bool b = false;
for (int i = 0; i < 255; i++)
{
if (pictureBox_OK.Image.Palette.Entries[i] == Properties.Resources.OK.Palette.Entries[i])
{
b = true;
}
else
{
b = false;
break;
}
}
|
|
|
|
|
Hi, In the below XML file, I would like add an element
studentMarks with attribute Total=100, where the Student ID=101.
I tried with InsertAfter method, but it didn't work.
Please guide me, Thanks in advance.
<? xml version = "1.0″ encoding = "UTF-8″?>
<StudentRecords>
<SpecialStudent id=555>
<StudentName> John Trivolta </StudentName>
<StudentSubject> Science </StudentSubject>
<SpecialStudent>
<Student ID=100>
<StudentName> John Trivolta </StudentName>
<StudentSubject> Science </StudentSubject>
</Student>
<Student ID=101>
<StudentName> Bruce Lee </StudentName>
<StudentSubject> Computer </StudentSubject>
</Student>
<Student ID=102>
<StudentName> North V </StudentName>
<StudentSubject> Maths</StudentSubject>
</Student>
<StudentRecords>
|
|
|
|
|
1. Get the XMLNode Student (of ID 101)
2. Get XMLNode StudentSubject
3. Call InsertAfter of Student node and pass StudentSubject node as reference node
4. And don't forget to save document
If you this didn't help, post ur code here to analyse
|
|
|
|
|
Thanks for the reply. Please look at my code. I'm getting exception at below line.
xmlDoc.DocumentElement.InsertAfter(newcatalogentry, refNode);
Exception message: "The reference node is not a child of this node."
XmlTextReader xmlReader = new XmlTextReader(Application.StartupPath + "\\doc.xml");
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(xmlReader);
xmlReader.Close();
string xpath = string.Format("/StudentRecords/Student");
XmlNamespaceManager nsmgr = new XmlNamespaceManager(xmlDoc.NameTable);
XmlNodeList fieldNodes = xmlDoc.SelectNodes(xpath, nsmgr);
string refName = "";
int index = 0;
XmlAttributeCollection ddd;
XmlNode refNode = null;
string studentID;
foreach (XmlNode node in fieldNodes)
{
ddd = fieldNodes[index].Attributes;
studentID = ddd["ID"].Value.ToString();
if (Convert.ToInt32(studentID) == 101)
{
refNode = node.SelectSingleNode("StudentSubject");
}
}
XmlDocument xmldoc = new XmlDocument();
XmlElement newcatalogentry = xmldoc.CreateElement("StudentMarks");
XmlAttribute newcatalogattr = xmldoc.CreateAttribute("Total");
newcatalogattr.Value = "100";
newcatalogentry.SetAttributeNode(newcatalogattr);
xmlDoc.DocumentElement.InsertAfter(newcatalogentry, refNode);
string path = "C:\\test.xml";
FileStream fsxml = new FileStream(path, FileMode.Truncate,
FileAccess.Write,
FileShare.ReadWrite);
xmlDoc.Save(path);
|
|
|
|
|
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(Application.StartupPath + "\\doc.xml");
string xpath = string.Format("/StudentRecords/Student");
XmlNodeList fieldNodes = xmlDoc.SelectNodes(xpath);
XmlNode studentNode = null;
XmlNode refNode = null;
foreach (XmlNode node in fieldNodes)
{
if (node.Attributes["ID"].Value == "101")
{
studentNode = node;
refNode = node.SelectSingleNode("StudentSubject");
}
}
if (studentNode != null && refNode != null)
{
XmlElement newcatalogentry = xmlDoc.CreateElement("StudentMarks");
XmlAttribute newcatalogattr = xmlDoc.CreateAttribute("Total");
newcatalogattr.Value = "100";
newcatalogentry.SetAttributeNode(newcatalogattr);
studentNode.InsertAfter(newcatalogentry, refNode);
string path = "C:\\test.xml";
xmlDoc.Save(path);
}
updated within post area, test it at your end
|
|
|
|
|
Thank you very much
|
|
|
|
|
In the below xml, I would like to add this element
<StudentClass ref="F_GAMES" /> after
<StudentClass ref="F_STRENGTH" /> where student id=101.
The below code is
Please correct the below code.. its wrongly updating the xml. Thanks in advance..
<?xml version="1.0"?>
<StudentRecords>
<Student ID="100">
<StudentClass id="XA" name="XA" >
<StudentClass ref="F_HEIGHT" />
<StudentClass ref="F_WEIGHT" />
<StudentClass ref="F_STRENGTH" />
<StudentClass ref="F_LIBRARY" />
<StudentClass ref="F_QUALIFIER" />
</StudentClass>
</Student>
<Student ID="101">
<StudentClass id="XB" name="XB" >
<StudentClass ref="F_HEIGHT" />
<StudentClass ref="F_WEIGHT" />
<StudentClass ref="F_STRENGTH" />
<StudentClass ref="F_LIBRARY" /> </StudentClass>
</Student>
</StudentRecords>
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(Application.StartupPath :-D + "\\doc.xml");
string xpath = string.Format("/StudentRecords/Student");
XmlNodeList fieldNodes = xmlDoc.SelectNodes(xpath);
XmlNode studentNode = null;
XmlNode refNode = null;
foreach (XmlNode node in fieldNodes)
{
if (node.Attributes["ID"].Value == "101")
{
fieldNodes = xmlDoc.SelectNodes(xpath + "/StudentClass");
XmlNode node1 = fieldNodes.Item(0);
studentNode = node1;
refNode = node1.SelectSingleNode("StudentClass");
break;
}
}
if (studentNode != null && refNode != null)
{
XmlElement newcatalogentry = xmlDoc.CreateElement("StudentClass");
XmlAttribute newcatalogattr = xmlDoc.CreateAttribute("ref");
newcatalogattr.Value = "F_NewCategory";
newcatalogentry.SetAttributeNode(newcatalogattr);
studentNode.InsertAfter(newcatalogentry, refNode);
string path = "C:\\test.xml";
xmlDoc.Save(path);
}
|
|
|
|
|
foreach (XmlNode node in fieldNodes)
{
if (node.Attributes["ID"].Value == "101")
{
fieldNodes = node.SelectNodes("/StudentClass");
if (fieldNodes != null && fieldNodes.Count > 0)
{
studentNode = fieldNodes.Item(0);
foreach (XmlNode nodeClass in studentNode.ChildNodes)
{
if (nodeClass.Attributes["ref"].Value == "F_STRENGTH")
{
refNode = nodeClass;
break;
}
}
}
break;
}
}
|
|
|
|
|
The value of fieldNodes.Count is 0. so the condition failed in the below if condition
if (fieldNodes != null && fieldNodes.Count > 0)
|
|
|
|
|
check line fieldNodes = node.SelectNodes("/StudentClass");
see other ways to get all StudentClass if it fails.
else try this
foreach (XmlNode node in fieldNodes)
{
if (node.Attributes["ID"].Value == "101")
{
studentNode = node["StudentClass"];
if(studentNode != null)
{
foreach (XmlNode nodeClass in studentNode.ChildNodes)
{
if (nodeClass.Attributes["ref"].Value == "F_STRENGTH")
{
refNode = nodeClass;
break;
}
}
}
break;
}
}
|
|
|
|
|
|
my pleasure
|
|
|
|
|
I am using following query to insert some large text data :
internal static string InsertStorageItem =
"insert into Storage(FolderName, MessageId, MessageDate, StorageData) values ('{0}', '{1}', '{2}', @StorageData)";
and the code I am using to execute this query is as follows :
string content = "very very large data";
string query = string.Format(InsertStorageItem, "Inbox", "AXOGTRR1445/DSDS587444WEE", "4/19/2010 11:11:03 AM");
var command = new SqlCeCommand(query, _sqlConnection);
var paramData = command.Parameters.Add("@StorageData", System.Data.SqlDbType.NText);
paramData.Value = content;
paramData.SourceColumn = "StorageData";
command.ExecuteNonQuery();
But at the last line I am getting this following error :
System.Data.SqlServerCe.SqlCeException was unhandled by user code
Message=The data was truncated while converting from one data type to another. [ Name of function(if known) = ]
Source=SQL Server Compact ADO.NET Data Provider
HResult=-2147467259
NativeError=25920
StackTrace:
at System.Data.SqlServerCe.SqlCeCommand.ProcessResults(Int32 hr)
at System.Data.SqlServerCe.SqlCeCommand.ExecuteCommandText(IntPtr& pCursor, Boolean& isBaseTableCursor)
at System.Data.SqlServerCe.SqlCeCommand.ExecuteCommand(CommandBehavior behavior, String method, ResultSetOptions options)
at System.Data.SqlServerCe.SqlCeCommand.ExecuteNonQuery()
at Chithi.Client.Exchange.ExchangeClient.SaveItem(Item item, Folder parentFolder)
at Chithi.Client.Exchange.ExchangeClient.DownloadNewMails(Folder folder)
at Chithi.Client.Exchange.ExchangeClient.SynchronizeParentChildFolder(WellKnownFolder wellknownFolder, Folder parentFolder)
at Chithi.Client.Exchange.ExchangeClient.SynchronizeFolders()
at Chithi.Client.Exchange.ExchangeClient.WorkerThreadDoWork(Object sender, DoWorkEventArgs e)
at System.ComponentModel.BackgroundWorker.OnDoWork(DoWorkEventArgs e)
at System.ComponentModel.BackgroundWorker.WorkerThreadStart(Object argument)
InnerException:
Now my question is how am I supposed to insert such large data to sqlce db?
|
|
|
|
|
You need to split it over several records as it is too large for the data type. Use a sequence number on each record to allow you to stitch it back together in the right order. As an alternative, would it be possible to put the data in a file and store the file details in the database?
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Hi Bob,
Thanks for your reply. Let me tell you one thing that I am going to create a desktop mail storage. Still I am not sure how to store the messages in an elegant way. This was my first try to store the content of the message in sqlce db. Is there any other better way to do this?
|
|
|
|
|
There is no nice solution. Each datatype of any database, be it sqlce, oracle, sybase or whatever has a size limit and there is no way around this. In the past when storing large data items I have had to split the data over several records and join them back together for display etc.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Anindya Chatterjee wrote: I am going to create a desktop mail storage
Let me know what are the step(s) you following currently....For example read email one after another and store it to the database....
Thanks
Md. Marufuzzaman
I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.
|
|
|
|
|
What I am following are a very simple steps as follows:
Start application
search for accounts in settings
if nothing found
show creation dialog
create folder and storage tables
save the settings
if found
check for folder structure
if not synchronized
create folders at folder table
add its parent folder if any
check for mails in each mail
if not uptodate
download mails for each folder and save to storage table
if uptodate
start the listeners
|
|
|
|
|
Hi.
Anybody know how to equivalent in C# following types :
CInternetSession session;
CHttpConnection* pServer = NULL;
CHttpFile* pFile = NULL;
Thanks .
We are haven't bug,just temporarily undecided problems.
|
|
|
|
|
HTTP stuff is contained in the System.Net[^] namespace. The WebRequest[^] class example demonstrates a typical usage scenario.
|
|
|
|
|
Hi,
Is there any .Net open source tool which basically detect all the devices which are connected over the connected network like Printer, Router etc ?
|
|
|
|