|
Hi,
I have the following problem. I create a file using the SaveFileDialog class. The file gets created in ANSI encoding, this according to many programs including notepad and MS Word. But then i try to write strings in non english languages and i get those symbols you know. OK, to try to solve this issue i set the text i want to write to UTF-8 encoding for international character support but the problem is: Have you ever tried to write utf-8 or variants to an ascii file? it's a mess!
Is there a way to solve this problem in any way? Creating the file with different encoding (don't know how to do this cause the file gets created in ascii by force) or changing it's encoding type later.
Thanx.
|
|
|
|
|
Hello
Heinz_ wrote: The file gets created in ANSI encoding, this according to many programs including notepad and MS Word.
Who in the world said that?!?!?
You can create your file in any format you want. Besides, if you want to write text in UTF-8, here is a sample:
SaveFileDialog save = new SaveFileDialog();
save.ShowDialog();
StreamWriter Fs = File.CreateText(save.FileName);
Fs.WriteLine("Test");
Fs.WriteLine("اختبار");
Fs.WriteLine("épreuve");
Fs.WriteLine("Prüfung");
Fs.WriteLine("试验");
Fs.WriteLine("試験");
Fs.Flush();
Regards
|
|
|
|
|
Hi, thanx for your answer and your code. I know taht your code works cause i have used this write method tons of time but this time i'm using the Stream class returned by SaveFileDialog.OpenFile(), this write method uses arrays of bytes to write to the files so characters in strings must be converted to bytes corresponding to the encoding type. This is where this encoding type compatibility game begins.
I think i'll have to recode this block of code again to use the great StreamWriter, thanks in advance,
Heinz
|
|
|
|
|
Nader Elshehabi wrote: Heinz_ wrote:
The file gets created in ANSI encoding, this according to many programs including notepad and MS Word.
Who in the world said that?!?!?
Regarding to this, when you call SaveFileDialog.ShowDialog() and the DialogResult is OK, or al least when you call SaveFileDialog.OpenFile(), your file gets created automatically and by force in an ANSI or ASCII formatting, check this info by opening the file with any word editing software that can show you the formatting type info.
This is how it works, i didn't say anything, don't blame me.
|
|
|
|
|
I tried the above write method, it works ok, it writes international characters (checked by opening it with notepad) and the encoding type of the file is UTF-8. The file i create and write is a csv.
I have another problem now, when i open this file with Excel these special characters are replaced by those weird symbols. Thats an Excel bug but how to solve it?
Thanks.
|
|
|
|
|
Hello
For this you have to check the language settings of Excel, or even your windows. Sorry, I don't think I can be of an assistance there.
Regards
|
|
|
|
|
hi all,in my web application link buttons are not working,it works well upto yesterday but today morning it's not working what will be the problem.in the link button click event,i just add the code to redirect the page nothing more.
what will be the prob.....i really struck with this prob....
Regards,
ayyp
|
|
|
|
|
If you use Visual Studio, it sometimes remove the click evnet in the "Web Form Designer generated code"
|
|
|
|
|
my application is actually a web application where i manually upload CSV file to the database.but i want to automate the process,so i have thought of a second stage to this application i.e through a windows application i would download the CSV file from the NSEIndia.com site automatically and then upload the same to SQLServer on the server.i dont have any idea about auto-upload i.e exporting the data to the database automatically.it would be a great help to me if any one could provide me a solution either in VB.Net code or C# code.
AMIT(TATA CMC)
-- modified at 4:51 Tuesday 11th July, 2006
|
|
|
|
|
Hello
amitcoder83 wrote: i am facing a problem with upload
Pardon me if I ask... What is exaclty your problem???
amitcoder83 wrote: if any one could provide me a solution
Indeed, but to what??
Regards
|
|
|
|
|
the actual problem is upload,i dont have any solution for automatic uploading can u give me a solution
Amit(TATA CMC)
|
|
|
|
|
Hello
There should not be any problem. Just work it out systematically.
1- You mentioned that downloading isn't a problem. So should the upload.
2- you got a CSV file, so you should parse it fist. I think that's easy, isn't it??
3- About the auto upload. If you mean for example that you put the files in a certain folder. Then when you launch the program it will automatically enumerate the files and upload them to our SQL server, hen what would be the problem here?
4- Uploading the values of the CSV files -or even the entire files without parsing-, is just a matter of connection to the sql server on the net. There are BOOKS on that, not just articles. Yet These following links may give you a push in the right direction:
CodeProjects Databse Page[^]
Especially this article:
Uploading / Downloading Pictures to / from a SQL Server[^]
After all that, I still have a bad feeling that I didn't get your problem correctly, did I? If so, posting the code that's causing you the problem would be helpful.
Remember that SQL server on the internet can be dealt with as if it's on a LAN or even on your PC -with some differences of course;)-. Just take care of the settings of the server.
Time to do some homework.
Regards
|
|
|
|
|
How I can write a custom control, like Add/Remove Programs List in Control Panel (Windows)?
|
|
|
|
|
Hello
Sashulika wrote: like Add/Remove Programs List
Like it in what exactly??
Ps.
There is a project named UserControl int he new projects list if that's all you want.
Regards
|
|
|
|
|
That's not a question that can be answered on a message board. Creating custom controls can be very complicated. You'll need to read whatever is in MSDN regarding custom control development. Then look for samples on CP. Who knows, there might already be a control that does what you need out on the web somewhere.
:josh:
My WPF Blog[^]
|
|
|
|
|
Hi All,
I have some int that i use in my project.
I need to print the value - but i must print it in 2 digit place.
I mean that if the int is 2 i need to print it as "02" and if its 15 it need to be as string "15".
How can i do it ?
Thanks for any help.
|
|
|
|
|
This[^] MSDN page lists all the custom numeric formatting strings. For your requirement, all you need to do is
int x = 2;
string formattedValue = x.ToString("00");
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Lets suppose that your int is i. Then you can use following code:
String intI=i.ToString();
if(intI[0]!='0')
intI="0"+intI;
Console.WriteLine(intI);
Regards,
Wasif Ehsan.
|
|
|
|
|
I am adding reference for microsoft outlook. i have selecting microsoft outlook 11.0 object library.
but in my code it gives error in c#.net 2005. but its working in visual studio 2003. Please help me.
Error:
The type or namespace name 'Interop' does not exist in the namespace 'Microsoft.Office' (are you missing an assembly reference?)
using System;
using System.Collections.Generic;
using System.Text;
//using System;
using System.Reflection; // to use Missing.Value
//TO DO: If you use the Microsoft Outlook 11.0 Object Library, uncomment the following line.
using Outlook = Microsoft.Office.Interop.Outlook;
namespace CheckOutlook
{
class Program
{
static void Main(string[] args)
{
try
{
// Create the Outlook application.
// in-line initialization
Outlook.Application oApp = new Outlook.Application();
// Get the MAPI namespace.
Outlook.NameSpace oNS = oApp.GetNamespace("mapi");
// Log on by using the default profile or existing session (no dialog box).
oNS.Logon(Missing.Value, Missing.Value, false, true);
// Alternate logon method that uses a specific profile name.
// TODO: If you use this logon method, specify the correct profile name
// and comment the previous Logon line.
//oNS.Logon("profilename",Missing.Value,false,true);
//Get the Inbox folder.
Outlook.MAPIFolder oInbox = oNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
//Get the Items collection in the Inbox folder.
Outlook.Items oItems = oInbox.Items;
// Get the first message.
// Because the Items folder may contain different item types,
// use explicit typecasting with the assignment.
Outlook.MailItem oMsg = (Outlook.MailItem)oItems.GetFirst();
//Output some common properties.
Console.WriteLine(oMsg.Subject);
Console.WriteLine(oMsg.SenderName);
Console.WriteLine(oMsg.ReceivedTime);
Console.WriteLine(oMsg.Body);
//Check for attachments.
int AttachCnt = oMsg.Attachments.Count;
Console.WriteLine("Attachments: " + AttachCnt.ToString());
//TO DO: If you use the Microsoft Outlook 10.0 Object Library, uncomment the following lines.
/*if (AttachCnt > 0)
{
for (int i = 1; i <= AttachCnt; i++)
Console.WriteLine(i.ToString() + "-" + oMsg.Attachments.Item(i).DisplayName);
}*/
//TO DO: If you use the Microsoft Outlook 11.0 Object Library, uncomment the following lines.
/*if (AttachCnt > 0)
{
for (int i = 1; i <= AttachCnt; i++)
Console.WriteLine(i.ToString() + "-" + oMsg.Attachments[i].DisplayName);
}*/
//Display the message.
oMsg.Display(true); //modal
//Log off.
oNS.Logoff();
//Explicitly release objects.
oMsg = null;
oItems = null;
oInbox = null;
oNS = null;
oApp = null;
}
//Error handler.
catch (Exception e)
{
Console.WriteLine("{0} Exception caught: ", e);
}
// Return value.
//return 0;
}
}
}
Prya
|
|
|
|
|
Hello
I believe your problem is not in the above code. It should be in your reference.
Revise it.
PS.
Please use the <pre> headers next time you post a code.
Regards
|
|
|
|
|
I am able to create a balloon tooltip from the systray of my application.
The problem is that the message displayed by the tooltip is a maximum of 256 characters.
I need the maximum to either be unlimited, or much bigger than 256 characters. Can anyone help me on how to do this?
I know there are a lot of examples on this site about it, I have tried them all except one that is copyrighted.. I don't want to use anyones code that is copyrighted..
Also: I am using a method that is before the supposed .NET 2.0 SDK tooltip handling because for some reason, even though I have .NET 2.0 SDK installed, I can't seem to access any of the balloon tooltip controls that it is supposed to have.. I really don't know why.. I also don't know if the .NET 2.0 balloon tooltip is limited to 256 characters also..
Any help anyone can give on this issue would be .. helpful
Thanks!
|
|
|
|
|
Hello
I tried to show a tooltip of more than 300 chars, using my .Net 2.0 framework & it worked fine.
I don't know about older versions!! Yet MSDN didn't mention any notices about 1.0 & 1.1 frameworks!! Personally I think the problem may be in your code.
Regards
|
|
|
|
|
That's interesting..
I am currently using balloon tooltip handling from before .NET 2.0 which is limited to 256 characters.. but if I could get .NET 2.0 SDK working that would be great..
Might you know why I can't use the 2.0 balloon functions/structures? I installed .NET 2.0 SDK and am using Microsoft Visual Studio .NET 2003 but I can't see any of the .NET 2.0 code for handling the balloons.
Perhaps I need to update the MSDN documentation? I really don't know.
|
|
|
|
|
Hello
Just in case that .Net 1.1 tooltip class doesn't support more than 256 chars - I must tell you I strongly doubt it!!-, you should change the reference of "system.windows.forms.dll" of your project to the dll file in your .Net 2.0 SDK's folder. Remember, don't add it. Change it.
Regards
|
|
|
|
|
omgwoot wrote: I installed .NET 2.0 SDK and am using Microsoft Visual Studio .NET 2003 but I can't see any of the .NET 2.0 code
You can't use VS 2003 with .Net 2.0. Either purchase an 2005 version of VS or just use one of the freely available Express editions. They can be installed side by side and not interfere with each other.
Don't try to mix them. You will fail.
|
|
|
|