|
Hello:
I have the next C# code:
r = new StreamReader("300_46C_UST04.txt", System.Text.Encoding.UTF7)
l = r.ReadLine()
The input file has the next data:
123+ABC3210_áéíóúñÑ\/ÁÉÍ--
After reading the record, variable "l" has:
123?_áéíóúñÑ\/ÁÉÍ--
It ignored the +ABC3210!! UTF is the best option for special characters such as Ñ, ñ, etc., but when the string has the character "+" .... it is terrible.
What Am I doing bad? I tried all the possibilities (with unicode, ascii, UTF8) but I have different results. When I delete the second parameter, i.e. System.Text.Encoding.UTF7, I obtain the next result:
123+ABC3210_\/--
(special characters where ignored!!)
Really, I do not understand.
Please .... a help?
|
|
|
|
|
What encoding is the file actually in? Did you create it?
If the file is in a certain encoding, you can get strange results when you read it with other encodings. Things get really crazy when unicode is involved, because there is not a simple 1 byte = 1 character mapping, especially when dealing with "special characters.
my blog
|
|
|
|
|
Hello Steven:
Thanks for your attention.
The input file was generated using notepad and I do not know the encoding used. Where can I check that? in my W2K parameters?
I live in Bolivia, South America, where Ñ, ñ, á ... etc. are very common.
I am very concerned about this problem because, I made many, many programs that read .txt information to load to a database and I fear that many of this spanish characters were lost. My God ... I never imagine this kind of problem.
My head (and my ass) are involved!!
What do you think I can do?
Best regards
|
|
|
|
|
You could try using System.Text.Encoding.Default for reading the file.
Because this uses the current system code page you should be able to read in files that have been written by other applications that are not concerned about encoding.
Regards,
mav
|
|
|
|
|
Notepad saves in ASCII.
/\ |_ E X E GG
|
|
|
|
|
Hi!
I am trying to load an image file, modify it (i.e. draw something into it for example) and save it again. I am so far:
Image img = Image.FromFile("test.jpg");<br />
Graphics g = Graphics.FromImage(img);<br />
g.DrawLine(System.Drawing.Pens.Black, 10, 10, 20, 20);
And now???? Now I have the thing in g (hopefully...). How do I get an Image of the Graphics object to save it using the Save method of Image? Or any other way to save it?? Or am I totally wrong? Some totally different method to accomplish the whole thing?
Thanks in advance and best regards,
Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
(doesn't work on NT)
|
|
|
|
|
You can just do img.Save("test.jpg", ImageFormat.Jpg)
and it will save the image.
When you draw using Graphics that was created from image, all the drawing is happening on the image surface, so if you save the image, all drawing will be kept.
|
|
|
|
|
Hello -
I have been working on a Windows App with three tabs in it (using the tabControl control). I have placed between 15 and 20 objects on each tab (labels, buttons, dropdowns, etc.) and made all of the backrounds transparent. Then I put a different image as the background of each tab, which creates this sort of watermark effect, which I really like. Unfortunately, when you swtich back and forth between the tabs in the .exe, it takes a few seconds each time to redraw all of the GUI objects, which looks pretty bad.
Does anyone have a solution for this problem? A way to draw the tab completely before displaying it? Background image as a GDI+ object? Double buffering?
Thanks,
jdrudolp
|
|
|
|
|
I've got a plugin arcitecture system that calls LoadFrom to load the .dlls in a specific folder and it works fine and dandy, imports everything, my code can create objects from types found in the loaded .dlls
HOWEVER, One issue i've not been able to solve is that, in some of the classes, I've got custom Type Editors for some of the classes in the "plugged in" .dlls
Whenever I set a created object from one of the plugged in .dlls and set it to a property grid's selected object, trying to edit it does not produce the correct type editor. This is especially the case with my custom collection classes. Since most of them are inherited from ArrayList, I constantly get the Object editor form.
Now here's the really wicked twist. If the plugins are set to references in my project in vs.net, The correct editors will appear just fine.
I did some debugging by getting a type for one of my collections that uses a custom editor, and wrote all the attributes from GetCustomAttributes method and the System.ComponentModel.EditorAttribute was still a recognized attribute on the class, eliminating my thought that perhaps the attribute was being lost during the LoadFrom.
I am totally baffled.
|
|
|
|
|
Totally a shot in the dark, but it seems like VS can't find the supporting dll's unless, as you said, you reference them.
Awful as it sounds, try putting your assemblies in the GAC. As I said though, this is a shot in the dark.
Marc
Microsoft MVP, Visual C#
MyXaml
MyXaml Blog
Hunt The Wumpus
RealDevs.Net
|
|
|
|
|
I'm getting "System.OutOfMemoryException" in a block of code that has not changed in quite a while. Actually it is an instantiation of a User Control. There are a series of 4 UC's instantiated. The first one has had changes made to it. The remaining have not. If I comment out the second one, the error goes away.
The problem is that the error doesn't show up until I do the Show() on the containing form. How do I figure out what causes an error like this when
1. No changes were made to this UC
2. An error doesn't occur when instantiating the UI
3. Memory does not peak at all
4. Changing the first UC back to it's original form corrects the problem.
Thanks.
|
|
|
|
|
Commented out basically the entire UC and kept uncommenting until I found the line of code causing the error. It wasn't an OutOfMemoryException, due to the other changes the code was hit a reference to a NULL object.
There's got to be a better way to track those down...but misleading error messages don't help. Still not sure why the error reported as it did (after the other two UCs created and then upon parent form doing its Show method) because the problem does get encountered during form creation.
|
|
|
|
|
After performing calculation, a data need to be displayed. But the function SetWindowText() can only take parameter in string data type. How to convert the int and float into text form so that it can be displayed in the dialog using edit box (in MFC)?
|
|
|
|
|
TehGT wrote:
(in MFC)?
This is C# foru,. Try it in VC++ forum.
Mazy
"One who dives deep gets the pearls,the burning desire for realization brings the goal nearer." - Babuji
|
|
|
|
|
Hello Dears
In a DataGrid control , how i can get the row number that has been selected by user ?
|
|
|
|
|
DataGrid.CurrentCell.RowNumber
Mazy
"One who dives deep gets the pearls,the burning desire for realization brings the goal nearer." - Babuji
|
|
|
|
|
Hello buddies,
We know if a table contains an autonumber column it is automatically increased each time a new record is inserted into ot.
I wana know what happens when this number reachs its maximum value, and whats the approach in this case?
Thank u so much,
- Den
|
|
|
|
|
EDden2Fly wrote:
I wana know what happens when this number reachs its maximum value, and whats the approach in this case?
Erm...this number is so big that you'd run out of disk space just to hold all the records way before you'd reach the max value, I would imagine.
If you use the decimal type with maximum precision, that's 10^38 unique identities! "bigint" is 9,223,372,036,854,775,807.
OK, if you use int (2Gb), smallint (32K), or tinyint (255), then yes, you'd have a problem.
So, what happens when you set an identity to a tinyint type and add the 256'th record?
Marc
Microsoft MVP, Visual C#
MyXaml
MyXaml Blog
Hunt The Wumpus
RealDevs.Net
|
|
|
|
|
An Exception of type SqlException is thrown with a message indicating an arithmetic overflow
Thank you so much Marc
- Den2Fly
---
"Art happens when you least expect it."
|
|
|
|
|
I use ado.net do something to mdb database. I found out the mdb database's size was been increased when it run some time.I can't confirm what it is cause.
It is my class,
using System;
using System.Data;
using System.Data.OleDb;
using System.Collections;
namespace RoadLib
{
///
/// NdnDataBase の概要の説明です。
///
public class NdnDataBase
{
protected string m_strConnectionString;
private OleDbConnection m_connection = null;
private OleDbTransaction m_transaction = null;
///
/// NdnDataBase の概要説明です
///
public NdnDataBase()
{
//
// TODO: コンストラクタ ロジックをここに追加してください。
//
m_connection = null;
}
///
/// NdnDataBase の概要説明です
///
/// <param name="strConnectionString" />
public NdnDataBase(string strConnectionString)
{
m_strConnectionString = strConnectionString;
m_connection = null;
}
///
/// DBコネクションを取得します
///
public OleDbConnection connection
{
get { return m_connection; }
}
///
/// DBトランザクションを取得します
///
public OleDbTransaction transaction
{
get { return m_transaction; }
}
///
/// データベースを開くために使用接続する
///
public string connectionString
{
get { return m_strConnectionString; }
set { m_strConnectionString = value;}
}
///
/// 指定のデータベースでセッションを開く
///
/// <returns>
public OleDbConnection DBOpen()
{
if(m_connection == null)
{
try
{
//データベース接続パラメータを取得
if (m_strConnectionString == "")
{
return null;
}
m_connection = new OleDbConnection(m_strConnectionString);
//DBオープン
m_connection.Open();
}
catch(Exception err)
{
//NdnPublicFunction.WriteLog(m_strLogFileName, err.Message);
m_connection = null;
throw (err);
}
}
return m_connection;
}
///
/// データベースでセッションを閉じる
///
/// <param name="connection" />
public void DBClose()
{
try
{
//DBクローズ
if (m_connection != null)
{
m_connection.Close();
}
}
catch
{
}
finally
{
//初期値を設定
m_transaction = null;
m_connection = null;
}
}
///
/// SQLステートメントを実行
///
/// <param name="strCommandText" />
/// <param name="connection" />
/// <param name="transaction" />
/// <returns>
public bool ExecSql(string strCommandText, OleDbConnection connection, OleDbTransaction transaction)
{
bool bReturn = false;
OleDbCommand dbCommand = new OleDbCommand(strCommandText, connection, transaction);
try
{
dbCommand.ExecuteNonQuery();
bReturn = true;
}
catch( Exception err)
{
throw (err);
}
return bReturn;
}
///
/// データベースでトランザクションを開始します
///
/// <returns>
public bool BeginTrans()
{
bool bReturn = false;
try
{
if (m_connection != null)
{
m_transaction = m_connection.BeginTransaction();
bReturn = true;
}
}
catch (Exception err)
{
throw err;
}
return bReturn;
}
///
/// データベースでトランザクションをコミットします
///
/// <returns>
public bool CommitTrans()
{
bool bReturn = false;
try
{
if (m_transaction != null)
{
m_transaction.Commit();
bReturn = true;
}
}
catch (Exception err)
{
throw err;
}
finally
{
m_transaction = null;
}
return bReturn;
}
///
/// データベースでトランザクションをロールバックします
///
/// <returns>
public bool RollbackTrans()
{
bool bReturn = false;
try
{
if (m_transaction != null)
{
m_transaction.Rollback();
bReturn = true;
}
}
catch (Exception err)
{
throw err;
}
finally
{
m_transaction = null;
}
return bReturn;
}
}
}
I use it to operate mdb database.
for example:
NdnDataBase database = new NdnDataBase("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\nara.mdb;User Id=admin;Password=;");
try
{
database.DBOpen();
database.BeginTrans();
database.ExecSql("Delete from ttt");
...
database.ExecSql("Insert into ttt values(1, 2)", database.connection, database.transaction);
database.CommitTrans();
...
}
catch
{
database.RollbackTrans();
}
finally
{
database.DBClose();
}
it operation is in a timer event.
At last, the database is bad.
|
|
|
|
|
What do you mean by "the database is bad"?
Without providing a more detailed error description it's very hard to help you!
Just one thing that comes to mind: Do you disable your timer while your function is executing? If not, the cause for your problems could be the timer re-entering the function while the previous timer event is still executing...
Regards,
mav
|
|
|
|
|
You may want to try Compact and Repair Database. We have a system that has the UI and Database separated. The front end never changes but it continues to grow just from using it! Since there is no data changes being made, I know that there are "features" in .mdb files that just need routine maintenance.
|
|
|
|
|
Access doesn't reclaim disk space when deleting or altering recrods until you tell it to do a compact and repair. Also, indexing sometimes places pads so that it can be better optimized. Really, it isn't a problem if you do regular housecleaning.
Marc
Microsoft MVP, Visual C#
MyXaml
MyXaml Blog
Hunt The Wumpus
RealDevs.Net
|
|
|
|
|
Dear friends!
I have a strange problem with C# and the Graphics-class.
My Form contains a pictureBox, on which a black and a red rectangle is drawn as soon as the user clicks on it. The Red Rectangle uses Color (200,255,0,0), so an Alpha value for transparency. The result can be seen here:
Link:http:\\www.bluecommerce.net\error.jpg
The code is:
Code:
private void pictureBox1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
SolidBrush pen1 = new SolidBrush(Color.FromArgb(200,255,0,0));
SolidBrush pen2 = new SolidBrush(Color.Black);
Graphics Graph = userControl1.CreateGraphics();
Graph.FillRectangle(pen2,e.X - 50,e.Y - 50,100,100);
Graph.FillRectangle(pen1,e.X - 50,e.Y - 50,100,100);
}
As you can see, the red rectangle is NOT rendered in the vincinity of the Mouse cursor (the mouse icon), you can see the black Rectangle through it. This happens ONLY if the Red Rectangle has an alhpa value which is NOT 0 or 255. 0 and 255 work of course.
This error happens only on my computer and a similar one (both have Windows 2000 and a Matrox G450 Millenium graphics card), on another computer with WinXP and another graphics card the same code works perfectly.
All current drivers and ServicePacks fpr GDI, GDI+, Windows 2000, Visual Studio .NET 1.0 (Service Pack 2) are installed.
Now, I would like to know if the error occures because of the
a.) Graphics card
b.) Windows 2000
c.) Visual Studio .NET
d.) GDI+
e.) my fault?
Who already encountered something similar and knows help?
I've already spent hours in searching at msdn and google, but did not find anything.
Thank you very much for your help.
Kind Regards
Marcel
|
|
|
|
|
Don't know if it really has something to do with the problem you're experiencing, but you could take a look at the color depth of your display.
I remember having troubles with the TransparencyKey of System.Windows.Forms.Form when used with 32bit color depth. Using 16 or 24 bpp worked fine, using 32bpp required a workaround to get transparency to work.
So if you're using 32bpp you should switch to 24bpp and test whether the problem still persists.
Regards,
mav
|
|
|
|
|