By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,658 Members | 1,519 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,658 IT Pros & Developers. It's quick & easy.

Culture-specific file size units ("KB" vs. "Koctets") ?

P: n/a
(If this is not posted in the right place, please let me know what the right
place is...)
I understand that French Windows Explorer uses "Ko" as the file size units
where English would use "KB". My C# application is going to display file
sizes and I would like it to use the correct string based on the user's
locale. Is there any way to get the correct string "Ko/KB/whatever" from
..NET or Windows?

-Russ
Nov 22 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
Russ,

Just an idea, why not ask this in a French newsgroup, they will answer you
probably directly even if you do it in English and excuse yourself for that.

Octet is of course a byte (8bits)

Cor
Nov 22 '05 #2

P: n/a
Not sure to understand the exact problem. Did you see what .NET offers for
application localization ? I would include these strings as resources in my
own application.The resource will be selected based on the language.

Do you have only this string to localize ?

Patrice

--

"RussC" <Ru***@discussions.microsoft.com> a écrit dans le message de
news:B1**********************************@microsof t.com...
(If this is not posted in the right place, please let me know what the right place is...)
I understand that French Windows Explorer uses "Ko" as the file size units
where English would use "KB". My C# application is going to display file
sizes and I would like it to use the correct string based on the user's
locale. Is there any way to get the correct string "Ko/KB/whatever" from
.NET or Windows?

-Russ

Nov 22 '05 #3

P: n/a
The application has lots of other strings to localize and we are already
using string resources which .NET retrieves based on culture. Certainly I
can include these strings in that way. I just thought it would be even
better if there was a way to somehow retrieve a string for file size units
from the environment somehow. After some looking I could not find such a way
-- but I thought I would ask the group if there was indeed a way to do that.
Maybe there isn't.

"Patrice" wrote:
Not sure to understand the exact problem. Did you see what .NET offers for
application localization ? I would include these strings as resources in my
own application.The resource will be selected based on the language.

Do you have only this string to localize ?

Patrice

--

"RussC" <Ru***@discussions.microsoft.com> a écrit dans le message de
news:B1**********************************@microsof t.com...
(If this is not posted in the right place, please let me know what the

right
place is...)
I understand that French Windows Explorer uses "Ko" as the file size units
where English would use "KB". My C# application is going to display file
sizes and I would like it to use the correct string based on the user's
locale. Is there any way to get the correct string "Ko/KB/whatever" from
.NET or Windows?

-Russ


Nov 22 '05 #4

P: n/a
What are the names of some French newsgroups that might be relevant?

Thanks,
Russ

"Cor Ligthert" wrote:
Russ,

Just an idea, why not ask this in a French newsgroup, they will answer you
probably directly even if you do it in English and excuse yourself for that.

Octet is of course a byte (8bits)

Cor

Nov 22 '05 #5

P: n/a
Russ,

I think that is not important, however you can take the program language you
use
something as

microsoft.public.fr.dotnet.csharp
or just
microsoft.public.fr.dotnet

Cor
What are the names of some French newsgroups that might be relevant?

Nov 22 '05 #6

P: n/a
Russ,
I don't know of a function to retrieve the information from Windows.

However you could set up a "string table" resource that you then localize.
Every place you need the string, you would retrieve the string wanted from
the resource.

Here are some MSDN articles that should get you started:

http://msdn.microsoft.com/library/de...nalization.asp

http://msdn.microsoft.com/library/de...gresources.asp

The directory structure itself is shown at the bottom of:

http://msdn.microsoft.com/library/de...assemblies.asp

When you use VS.NET to create your international resources VS.NET create the
folder structure needed in the bin (output) folder.

I normally use .resx files with VS.NET...

Hope this helps
Jay
"RussC" <Ru***@discussions.microsoft.com> wrote in message
news:B1**********************************@microsof t.com...
(If this is not posted in the right place, please let me know what the
right
place is...)
I understand that French Windows Explorer uses "Ko" as the file size units
where English would use "KB". My C# application is going to display file
sizes and I would like it to use the correct string based on the user's
locale. Is there any way to get the correct string "Ko/KB/whatever" from
.NET or Windows?

-Russ

Nov 22 '05 #7

P: n/a
I understand that French Windows Explorer uses "Ko" as the file size units
where English would use "KB". My C# application is going to display file
sizes and I would like it to use the correct string based on the user's
locale. Is there any way to get the correct string "Ko/KB/whatever" from
.NET or Windows?


There are a few Win32 APIs for formatting file sizes;
StrFormatByteSize* for returning the size scaled to the "best" 1024
multiple, or StrFormatKBSize if you always want the unit to be KB.

http://msdn.microsoft.com/library/en...bytesize64.asp
http://msdn.microsoft.com/library/en...rmatkbsize.asp

If you prefer to roll your own algorithm and just need the string,
these are available as string resources 259 - 265 in Shlwapi.dll. I
assume these are localized appropriately, but I don't have a french
system to verify it on.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 22 '05 #8

P: n/a
My personal preference would be still to keep this string in my own
resources :
- simplicity, I don't feel really clean to use resources for all except this
one (plus it could change, break or whetever)
- you could have an inconsistent UI ie. having the size units localized but
all else using the default language (if you have no translations for this
particular language).

Patrice
--

"Mattias Sjögren" <ma********************@mvps.org> a écrit dans le message
de news:O4**************@TK2MSFTNGP11.phx.gbl...
I understand that French Windows Explorer uses "Ko" as the file size unitswhere English would use "KB". My C# application is going to display file
sizes and I would like it to use the correct string based on the user's
locale. Is there any way to get the correct string "Ko/KB/whatever" from
.NET or Windows?
There are a few Win32 APIs for formatting file sizes;
StrFormatByteSize* for returning the size scaled to the "best" 1024
multiple, or StrFormatKBSize if you always want the unit to be KB.

http://msdn.microsoft.com/library/en...bytesize64.asp http://msdn.microsoft.com/library/en...rmatkbsize.asp
If you prefer to roll your own algorithm and just need the string,
these are available as string resources 259 - 265 in Shlwapi.dll. I
assume these are localized appropriately, but I don't have a french
system to verify it on.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Nov 22 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.