|
No, timestamps are not in hex. Hexadecimal is only a numeric representation. They're a number and that's all. To actually be stored in hex would require storing a string, which I know is now the case.
To convert numbers to a filetime, you can pass the number (a long , or Int64 ) to either of the static DateTime.FromFileTime or DateTime.FromFileTimeUtc methods. In your case, you'll want to use DateTime.FromFileTimeUtc since timestamps are specified in UTC (+0 GMT).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hello,
I am wondering how to develop an application with multi-language. What's the common practise for this? I don't think people will change every single word from English to other language. Any good approach for this?
Thanks,
Leo
|
|
|
|
|
luozhan1 wrote:
I don't think people will change every single word from English to other language.
That would really piss off people. Imagine if I am using an application like IE and I have a Menu called "Archivo" (Spanish for file) and then in that menu (because you couldn't be bother to change all the words) were "Open" and "Exit" instead of "Abrir" and "Cerrar". That would be confusing (especially as Exit is very similar to the Spanish word for "success")
luozhan1 wrote:
Any good approach for this?
You should read up on the subjects of Localisation, Globalisation and Internationalisation (you may need to replace my -sation with -zation as I am localised to UK-English and the documentation is in US-English)
Do you want to know more?
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and Forums
|
|
|
|
|
Colin Angus Mackay wrote:
That would really piss off people.
That's a good way of putting it. Here at Microsoft and other global companies geopolitical issues are a major concern. What you may not find offensive some other group of people may.
There are books on this issue. One that's required reading here is Developing International Software, Second Edition[^]. It's definitely worth a read if you're seriously planning on localizing your code.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
The SDK has a wealth of information on localisation (long live Australian English! ); in fact I just started reading up on the topic myself - I want to implement localisation into my ASP.NET applications for work.
The common approach (from what I have been reading) is to use satellite assemblies which are loaded dynamically depending on the user's current CultureInfo.CurrentUICulture setting. If a satellite assembly isn't available for their UI culture, use the default.
However, I don't know anything more than that - I haven't even got it working myself yet
This space for rent!
My Blog
|
|
|
|
|
|
Those are for ASP.NET. Assuming they did it the right way, Windows Forms applications are still localized a little differently.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
You should start by reading Developing World-Ready Applications[^] in the .NET Framework SDK.
Basically, in whatever language you develop your application, that text (and other objects which have an associated TypeConverter ) is your neutral resource language and is compiled into your primary assembly (the assembly that contains the IL modules compiled from your code. Any other languages you develop are put into satellite assemblies.
If you're using VS.NET this is very easy (but, until "Whidbey", pretty inefficient at runtime for larger applications). Develop your forms and controls, then select the top-level control (like the Form or UserControl ) and find the Localized property (this is actually a design-time property; it is not defined on the class). Set that to true then find the Language property (again, a design-time property). Set that to something else and change the text, positions and sizes of controls, etc.
If you want to see what VS.NET is doing behind the scenes, click Project->Show hidden files from the menu. You'll see a lot of .ResX files nested underneat your control class files. The neutral resource .ResX will not have an ISO lang/locale identifier (like MyClass.resx) while the others will (like MyClass.de-DE.resx or MyClass.es.resx, which are resource files for Germany (German language) and the Spanish language (no locale), respectively.
When you compile your application, satellite assemblies are created. If you then look into your source code, expand the hidden regions and you'll see lots of calls to ResourceManager.GetString or ResourceManager.GetObject (actually, an instance of ResourceManager typically named resources ).
When the CultureInfo.CurrentUICulture (not CurrentCulture , which is used for formatting dates, times, and numbers - it specifies the locale, not the language) is set the ResourceManager will try to find a language for that. If any locale is specified in that CultureInfo instance, that locale will be used if it exists. If not the fallback is the language. If a satellite assembly doesn't exist for that, the neutral resources - those inside your primary assembly - are used.
To make this faster, in your AssemblyInfo.cs file (actually, wherever is fine) define the assembly-level attribute NeutralResourcesLanguage set to the "lang-locale" for the language in which your project is developed, like "en-US" for US English. If the ResourceManager needs to find those reosurces, it will not not to go probing for them (which is especially slow if deploying your managed application using touchless deployment across the Internet or even an intranet).
Be sure to read that link I gave you, as well as some of the classes you'll be using like ResourceManager and CultureInfo . Taking a look at what VS.NET does (because that's about what you'd do if you did it manually) is also extremely helpful.
If you use VS.NET to do this your clients can even localize your application without the source using winres.exe from the .NET Framework SDK, or a separate localization team if you have such an entity. You can use this if you do it manually, but you must understand what is required that winres.exe looks for, which you can learn by looking to see what VS.NET does.
Here's the catch: VS.NET declares instantiates the ResourceManager in InitializeComponents . If you want to support switching languages in the middle of the application (which you can do by setting CultureInfo.CurrentUICulture , then you'll need to re-initialize - not re-instantiate - your controls. To do this efficiently you'll need to break VS.NET's design-time support by abstracting the initialization out of InitializeComponents , leaving only the instantiation in there (or more the instantiation to another method). This means you can call a method to re-initialize the controls (how you trigger this is up to you). This is pretty uncommon for larger projects, as many problems can occur and since most people don't need to switch languages in the middle of a Windows session.
Note, too, that MUI (multi-user interfaces API) automatically sets CultureInfo.CurrentUICulture (actually, the property is initialized from the current MUI language). So, if a user is using a German Windows installation or the German MUI as I sometimes do, CultureInfo.CurrentUICulture would automatically be set to "de-DE" so your application - if localized for "de-DE" or just "de" - would automatically display your German text and control positions, sizes, etc.
If you'd like more information about how "Whidbey" is improving efficency while using the designer to localize applications, read my blog entry at http://blogs.msdn.com/heaths/archive/2004/10/05/237987.aspx[^].
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
|
You should look over the System.Drawing and System.Drawing.Drawing2D namespaces. C# has a rich API for drawing many of the things you mention (e.g. gradients, buttons, etc.) Here is a short tutorial on some basic drawing/painting functions: http://www.c-sharpcorner.com/2/gdi_plus.asp[^]
You should also look into Pens, Brushes, Patterns, and Alpha Blending (Transparency)[^].
Best Regards.
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
I am using a security dongle (clients request) and am having some problems with it. They have released a .net component to talk to the device. I have tried speaking to them about my problem, but they are on the other side of the planet, and communication is way to slow.
Ok, this code works 100% in any C# program, except asp.net. I am not going to give you the code I am using, as it would be of no use in this problem. The dll attempts to connect to a USB port on the computer. However, in asp.net this fails.
So my question is this: The asp.net page does not actually need to connect to the device, as all it needs to do is store some information on there. What sort of component should I make that can be called from asp.net? I have not used COM or windows services, or anything else like that, so am not sure if one of these could help me. Please let me know how I can call a method in a remote object to do this work for me?
|
|
|
|
|
Is the asp.net executing on the local machine or on a remote server ?
Due to obvious security issues you can't access the local file system from a webpage and nor can you access any device.
The only workaround would be to use a smart client.
"Do not inflate plain things into marvels, but reduce marvels to plain things." - Francis Bacon
|
|
|
|
|
What do you mean by a smart client? The asp.net is on the local machine.
|
|
|
|
|
A smart client is like half way between asp.net and windows forms :
example[^]
Since its local I would think about the permisions of the asp.net user and the runtime security policy. Perhaps if you give it full permission and full trust and see if that works ?
"Do not inflate plain things into marvels, but reduce marvels to plain things." - Francis Bacon
|
|
|
|
|
HI,
I have some 5 lines of text already entered into the text file.
Is there any possible way to enter the next line as the first line and not just append it to the end.
Regards,
Sukanya
|
|
|
|
|
|
I have to this programmatically in C#.
I already have written some text into the file using C#. I want insert the next line as the first line of the text file.
but by default it always inserts it at the end.
pls help
I am working on that
Regards
Sukanya
|
|
|
|
|
You'll have to read the entire file, append your text on the beginning and then write the whole file again.
This space for rent!
My Blog
|
|
|
|
|
Try using a StreamWriter to write to your file. The underlying stream, which is accessible through the BaseStream property provides a Position property which should allow you to position at the front of the stream/file.
www.troschuetz.de
|
|
|
|
|
In short, you cannot INSERT anything anywhere you want in a text file in a single, simple operation. Unless, of course, you want to APPEND to the end of the file.
If you want to insert text as the first lines in the file, you'll have to do one of two things:
1) Open the file; Read the entire contents of the text file into memory; Close the file; Reopen it as a new file; Write out the text you want to insert at the beginning of the file; Write out the contents that you saved; Close the file
2) Rename the file to some temporary name; Open a new file with the name you want; Write out the text you want to insert; Open the temporary file; Read it in, line by line, and write it out to the new file, line by line; Close both files
Method 1 will work very fast is better on samller files. Method 2 will work better for very large files, or files that you can't know the size of ahead of time, or files that exceed RAM capacity, but is slower.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I'm trying to find the most effecient way/most elegant way to do this. I have a Combo box that has a list of network types (all corresponding to System.Net.NetworkInformation.InterfaceType ). Now I have an if statement that is dependent on what is selected in this combo box. e.g. if "Ethernet" is selected it will be if(interfaces[i].Type == InterfaceType.Ethernet) . Now I know I could just do a massive if nesting but I want to know what you guys think would be best.
Matt Newman
Even the very best tools in the hands of an idiot will produce something of little or no value. - Chris Meech on Idiots
|
|
|
|
|
It depends what you want to do. If you are just setting a variable or two based on the result, I'd build a hashtable of type to return value, and set it in one line.
Either way, I'd always use a switch over massive if/else blocks.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Basically I am enumerating all of the network adapters on the system and then allowing the user to specify which type to view (only the type selected are shown). It is really only used once.
Matt Newman
Even the very best tools in the hands of an idiot will produce something of little or no value. - Chris Meech on Idiots
|
|
|
|
|
I reckon the trick is to make the value associated with the strings in the drop down equal the enum value, if that's all you need. Or, better yet, use Enum.Parse to make an enum value out of the string, and use Enum.(whatever the method is that returns a string array from an enum ) to populate it.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Keep in mind that InterfaceType has a backing value type of Int32. My experience with Windows Forms is limited, but if you could get an index value of some type from the combobox, you could cast that value to a variable of type InterfaceType.
i.e.:
InterfaceType selectedType = (InterfaceType) val;
(where val is the index number pulled in through the combobox)
Then you'd only have one conditional statement checking for equality:
if (interfaces[i].Type == selectedType)
Hope this helps!
~ Levi
|
|
|
|
|