473,395 Members | 1,730 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Error Restoring Signature (Hexadecimal format)

Hi everybody,
I am problem with restoring data of byte[] type to be loaded on an Ink
object. The data
was earlier converted to byte[] then finally to hexadecimal data and store
on a text file.
Is there anyone who can help me solve this problem. Thanks.

Note: The Ink object is from Microsoft.Ink namespace.

Code:

private void LoadXML()
{
try
{
// This object will encode our byte data to a UTF8 string
UTF8Encoding utf8 = new UTF8Encoding();

Ink loadedInk = new Ink();

string filePath = Application.StartupPath + "\\siganture.txt" +

StreamReader sreader = new StreamReader(filePath);

string Signature = sreader.ReadToEnd();

// load the ink into a new ink object
// once an ink object has been "dirtied" it can never load ink again

loadedInk.Load(utf8.GetBytes(strSignature)); <- Error Occurs here
// temporarily disable the ink collector and swap ink objects
ic.Enabled = false;
ic.Ink = loadedInk;
ic.Enabled = true;

// Repaint the inkable region

this.pictureBox.Invalidate();
}
catch (Exception ex)
{
//error handling processes
}
}

Error Message:

"System.Runtime.InteropServices.COMException (0x8000FFFF): Catastrophic
failure\r\n at Microsoft.Ink.InkDispClass.Load(Object Data)\r\n at
Microsoft.Ink.Ink.Load(Byte[] inkdata)\r\n at SignatureForm.LoadSiganture()
in c:\\....\\signatureform.cs:line 2163\r\n at
signatureForm.btnCancel_Click(Object sender, EventArgs e) in
c:\\...\\signatureform.cs:line 705\r\n at
System.Windows.Forms.Control.OnClick(EventArgs e)\r\n at
System.Windows.Forms.Button.OnClick(EventArgs e)\r\n at
System.Windows.Forms.Button.OnMouseUp(MouseEventAr gs mevent)\r\n at
System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button,
Int32 clicks)\r\n at System.Windows.Forms.Control.WndProc(Message& m)\r\n
at System.Windows.Forms.ButtonBase.WndProc(Message& m)\r\n at
System.Windows.Forms.Button.WndProc(Message& m)\r\n at
System.Windows.Forms.ControlNativeWindow.OnMessage (Message& m)\r\n
at System.Windows.Forms.ControlNativeWindow.WndProc(M essage& m)\r\n at
System.Windows.Forms.NativeWindow.DebuggableCallba ck(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)\r\n at
System.Windows.Forms.UnsafeNativeMethods.DispatchM essageW(MSG& msg)\r\n at
System.Windows.Forms.ComponentManager.System.Windo ws.Forms.UnsafeNativeMethods+IMsoComponentManager. FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData)\r\n at
System.Windows.Forms.ThreadContext.RunMessageLoopI nner(Int32 reason,
ApplicationContext context)\r\n at
System.Windows.Forms.ThreadContext.RunMessageLoop( Int32 reason,
ApplicationContext context)\r\n at
System.Windows.Forms.Application.Run(Form mainForm)\r\n at MainForm.Main()
in c:\\....\\mainform.cs:line 557"

den2005
--
MCP Year 2005, Philippines
Nov 17 '05 #1
1 1902
den 2005 <de*****@discussions.microsoft.com> wrote:
Hi everybody,
I am problem with restoring data of byte[] type to be loaded on an Ink
object. The data
was earlier converted to byte[] then finally to hexadecimal data and store
on a text file.
Is there anyone who can help me solve this problem. Thanks.


Okay, your problem has nothing to do with ink. It's just converting
between text data and binary data.

You've got binary data which has been hex-encoded. So to get back to
the binary data, you need to *decode* it from hex - currently you're
just getting the string encoded in UTF-8. See
http://www.pobox.com/~skeet/csharp/unicode.html for information about
encodings to understand what's going on.

Now, there's nothing built into the framework (as far as I know) to
decode a whole hex string. If you can change the format of the file, it
would be easier to use Base64 - then you can use Convert.ToBase64String
and Convert.FromBase64String.

Otherwise, just loop through pairs of characters, converting each to a
byte. I'm sure I had some code somewhere on a newsgroup to do this, but
I can't find it right now...

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Pushpendra | last post by:
I am storing the encrypted password in xml file which I have saved in unicode format. While I try to read the xml file and create a dataset from it, it shows me the following error ...
0
by: lonnie.lewis | last post by:
Hi all, I'm a consumer of a web service which is defining an output parameter as an "xsd:anyType": <message name="MyTransaction.IsWebServicesDataValid"> ... <part name="varDisplayMessage"...
8
by: Vijay | last post by:
Hi , I am doing a small project in c. I have a Hexadecimal file and want to convert into ascii value. (i.e., Hexadecimal to Ascii conversion from a file). Could anyone help me? Thanks in...
25
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - Why does parseInt('09') give an error? ----------------------------------------------------------------------- ...
5
by: Troels Arvin | last post by:
Hello, Every so often, I'm asked to help people recover data from tables that were either dropped or where to much data was DELETEed. The complications related to restoring data are a problem....
6
by: Andrea | last post by:
Hi, suppose that I have a string that is an hexadecimal number, in order to print this string I have to do: void print_hex(unsigned char *bs, unsigned int n){ int i; for (i=0;i<n;i++){...
6
by: sweeet_addiction16 | last post by:
hello Im writin a code in c... can sum1 pls help me out in writing a c code to convert decimalnumber to hexadecimal number.The hexadecimal number generated has to be an unsigned long.
1
by: keerthikarani | last post by:
hi, I m using the following code in vb.net, but it shows me some error, can u explain why this error occurs and how to rectify it, but the following code works fine in vb Private Declare...
1
by: babu | last post by:
Hi all I am trying to take exchange server 2003 backup and restore programmatically. My backup function works fine. But i am in problem in restoring database. My HrESERestoreAddDatabase is not...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.