|
Thanks I tried your code below and it has helped a lot
public static int GetByteCount(string input)
{
int intByteCount =0;
System.Text.Encoding sjisEnc =
System.Text.Encoding.GetEncoding("Shift_JIS");
intByteCount = sjisEnc.GetByteCount(input);
return intByteCount;
}
string inputText = "。「」、・ヲァィゥェォャュョッーアイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン゙ 契約管理明細書゚";
for (int z = 0; z < inputText.Length; z++)
{
if(2 * inputText[z].ToString().Length == GetByteCount(inputText[z].ToString()))
{
System.Windows.Forms.MessageBox.Show("全角です。- Double Byte " + inputText[z].ToString());
}
else if(inputText[z].ToString().Length == GetByteCount(inputText[z].ToString() ) )
{
System.Windows.Forms.MessageBox.Show("半角です。- Single Byte " + inputText[z].ToString());
}
}
If I get further with the conversion work I will post back to here.
Regards
Satvinder
|
|
|
|
|
I'm developing an application in VS.Net 2003 using C#, which uses Crystal
Reports.
My report connects to an Access DB.
Does anyone know how to reset the datasource at runtime? My app is currently linked to the datasource I specified at design time. This datasource will change once the app is installed on the client's machine.
Thanks.
|
|
|
|
|
Have you looked at the code in the C# sample from MSDN for Crystal Reports? I'm pretty sure the actual .rpt file changes at runtime for displaying which report, but I don't know about the actual datasource. I'm sure it has to be possible, because I know that most people making apps with CR aren't hard-coding the datasource names before distributing their apps. Anyway, if you haven't downloaded the samples, here's the link:
http://download.microsoft.com/download/6/4/7/6474467e-b2b7-40ea-a478-1d3296e78adf/CSharp.msi
[^]
If I write code in my sleep, does that make me brilliant, or just a lazy programmer?
My articles
www.stillwaterexpress.com
BlackDice - the programmer formerly known as bdiamond
|
|
|
|
|
Thanks for the link... the samples were very helpful
|
|
|
|
|
I am trying to figure out how i can make the generated typed datasets from VS 2003 us my dataSet base class instead of the System.Data.DataSet base class.
The generated code produce this:
public class AR_CustMaster : DataSet {}
I need the dataset generator to produce this:
public class AR_CustMaster : MyNameSpace.MyDataSet {}
I know i can go in the generated .cs file and manually change it but as soon as the dataset is regenerated, my changes are lost.
Is there any way to make the change permanent ?
|
|
|
|
|
When ur finished designing the dataset and u have it just as u want it, copy and paste the generated code to a new file. I dont think there is any other solution for what ur asking.
|
|
|
|
|
I am trying to format an integer to a string with leading zeros:
This works:
int i = 1234
Console.WriteLine("{0:0000000000}",i);
But what about make formats for new strings or saving in string variables ?
string strLine = new String("{0:00000}",i);
--> Cannot work caused by constructor parameter collision. By the way, var "i" is generic. So no solutions with constants and other literals.
Thanks for all advice in advance.
|
|
|
|
|
Ok, lets look under the hood of what works:
Console.WriteLine(string,params object[])
which you are calling internally calls
Console.Out.WriteLine(string, params object[])
Console.Out is a TextWriter instance, so:
TextWriter.WriteLine(string, params object[])
Internally this calls
String.Format(String,params object[] args);
so finally in answer to your question this will work:
string strLine = String.Format("{0:00000}",i);
HTH
|
|
|
|
|
|
How to access WAB(windows address book) from c#?
It is my start:
static public extern uint WABOpen(ref System.IntPtr lppAdrBook, ref System.IntPtr lppWABObject,ref System.IntPtr lpWABParam, uint Reserved2);
|
|
|
|
|
The following code is part of my program:
<br />
string folderToWatch = @"d:\html\";<br />
FileSystemWatcher fsw = new FileSystemWatcher(folderToWatch, "*.html");<br />
<br />
fsw.Created +=new FileSystemEventHandler(OnCreated);<br />
<br />
fsw.EnableRaisingEvents = true;<br />
It works perfectly om my laptop running Windows XP SP2. But not at the server running Windows Server 2003.
Any suggestions why?
--------
sander99
|
|
|
|
|
sander99 wrote:
It works perfectly om my laptop running Windows XP SP2. But not at the server running Windows Server 2003.
Any suggestions why?
What are the rights of the user running the application has on the fold being watched?
Yes, even I am blogging now!
|
|
|
|
|
For testing purpose the process is ran by the Administrater - so this should not be the problem.
|
|
|
|
|
I'm not sure of the underlying API's that the FileSystemWatcher class uses, but I know of a problem with using ReadDirectoryChangesW() for the Windows API. When I was using this function in a C++ project, it wouldn't work because the folder was actually a unix drive that was mapped to my machine, and looked like a regular windows folder. So I don't know if that class is using the same API underneath, but that API doesn't work on non-Windows drives. Your problem may be different, but possibly related. This may not even be near what the actual problem is, but hopefully it might get you thinking about any other possible anomalies in the way that folder is accessed.
If I write code in my sleep, does that make me brilliant, or just a lazy programmer?
My articles
www.stillwaterexpress.com
BlackDice - the programmer formerly known as bdiamond
|
|
|
|
|
Hi!
I was wondering how I could manually create a RCW for third-party ActiveX controls.
Creating 'regular' RCW's for COM dlls is quite straightforward, just running the dll through tlbimp.exe and I get the RCW.
Now when I add an ActiveX control to a form with VS, an AxInterop.Componentname.dll is created, along with Interop.Componentname.dll.
The second dll (Interop.*) seems to be equivalent to what I can create with tlbimp.exe, but what about the AxInterop.* ?
Can anyone shed some light on this subject?
TIA,
Mav
|
|
|
|
|
mav.northwind wrote:
but what about the AxInterop.* ?
Mav, the AxInterop assembly that is created literally wraps the ActiveX control to expose it as a Windows Forms control, it's base class is AxHost . You typically wouldn't want to create this manually, however you can use the Aximp.exe[^] (Windows Forms ActiveX Control Importer) to generate this assembly yourself.
- Nick Parker My Blog | My Articles
|
|
|
|
|
Thanks alot, Nick!
I was asking because I have to support two different versions of a third party program exposing ActiveX controls and COM objects in my program.
The problem is that the interfaces of these objects have changed but have kept the same name. So I couldn't find a way to instantiate a class implementing a specific interface version and am now trying to use 2 RCW dlls with different namespaces.
Don't know if this will work, though.
The core problem is: I can't have both versions of the application installed at the same time, so I must build against the version currently installed. When I build against the newer version, I'll get class not registered-errors when instantiating objects with the older version installed. The other way round I can't use any features from the newer version.
You don't have an idea how to do this by chance?
Thanks,
Mav
|
|
|
|
|
I am doing some code profiling on my project to try and identify any speed bottlenecks - I am using DevPartner community edition from Compuware - when I run the tests my project spends about 90% in WaitForSingleObject, Sleep and SleepEx - why would it do that? The program isn't multithreaded and the main part of the program I am testing has no user interraction - it's basically some IO and a lot of bit shifting.
TIA
|
|
|
|
|
PaleyX wrote:
it's basically some IO
You have to wait for the I/O finish. Often this is done by the CLR using WaitForSingleObject, because some I/O classes only implement asynchronous interfaces (Begin*/End*) - the synchronous versions of these methods simply call the Begin/End pair.
What you're seeing is that your program is spending 90% of the time blocked by I/O. Maybe multithreading would help you a bit.
Yes, even I am blogging now!
|
|
|
|
|
Thanks for that. It isn't really a problem as the program is fast enough - analyse 1 billion records per second anybody? I was just curious why it was spending so much time sleeping and waiting.
Rugby League: The Greatest Game Of All.
|
|
|
|
|
hi all,
I want to find CRC32 value of any kind of file(*txt,*.jpg,etc....) using C#..
Can u please help me how to find that value?
Thanks in advance..
|
|
|
|
|
Hi,
Does anybody has any idea how to give implementation in c-sharp, of the following feature of Yahoo or MSN:
Show me as "Away" when I am inactive for 10 minutes.
I have a chat client application developed in c-sharp. And now I want to give the same feature in my app too.
Prompt reply will be appreciated.
Regards,
Kamran
|
|
|
|
|
You could take a timestamp everytime the user of your application does something and store it somewhere. This timestamp value then gets compared with the actual time inside of an timer event handler and if the difference is greater than 10 min you set the status to "Away".
www.troschuetz.de
|
|
|
|
|
Simple solution - have a timer that ticks every so often (depending on how accurate you want your away timer to be)
Every time the timer ticks, increment the counter, when the counter goes above a pre-set value (i.e. how ever many timer ticks there are in 10 minutes) you can set your status to away.
Now, in any of your mouse/keyboard handlers, just reset that counter to zero if you've got user input
--
Help me! I'm turning into a grapefruit!
Phoenix Paint - back from DPaint's ashes!
|
|
|
|
|
Hi Benjymouse,
Thanks for your prompt reply. It helps me a lot to understand the solution.
But how to capture mouse/keyboard events of windows. Remember my chat application application needs to be notified of any activity on windows for example if my chat application is minimized, and a user only moves his mouse on the desktop, my application should be able to capture this event.
I hope you understand what i mean.
Regards,
Kamran
dearkami@yahoo.com
|
|
|
|