|
Something like this?
using System.Globalization
CultureInfo ci = new CultureInfo("es-ES");
NumberFormatInfo myFormat = ci.NumberFormat;
myFormat.NumberGroupSeparator = ",";
myFormat.NumberDecimalDigits = 2;
string MyFormattedString = MyDoubleValue.ToString("N", myFormat); The endusers' culture should determine how the number is formatted. That's usually configured in the Windows regional settings.
I are Troll
|
|
|
|
|
Hello,
I am creating a directory programatically (C#) to store some application specific data. I want that this directory should't be deleted or modified while the application is running but once the application is closed, it can be modified or deleted. Also, all user on the machine should have similar rights for that folder.
How do I achieve this? Any help in this direction will be greatly appreciated.
Thanks.
|
|
|
|
|
I think this can be achieved with the FileSystemAccessRule class (the creation of the rule(s) that is). Then you create a DirectorySecurity ojbect and use the AddAccessRule method to apply your access rule(s). Finally, create a DirectoryInfo object representing the folder and run the SetAccessControl method which takes your DirectorySecurity object as an argument.
That's pretty much how I've done it in the past. Good luck!
|
|
|
|
|
Thanks for reply.
I am using security like this:
AccessRule rule = new FileSystemAccessRule("Users",
FileSystemRights.Write |
FileSystemRights.ReadAndExecute ,
InheritanceFlags.ContainerInherit |
InheritanceFlags.ObjectInherit,
PropagationFlags.InheritOnly,
AccessControlType.Deny);
Still I am able to delete the folder manually.
Thanks.
|
|
|
|
|
You could open a file (located in the folder) with exclusive read/write, and any attempt to delete the folder will fail as long as that file is opened.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
Yeah.. That's good idea.
The only concern is that folder can't be deleted but other containts of the folder can be deleted one by one.
Anyway, this solution might resolve my problem.
Thanks.
|
|
|
|
|
The only thing you can do is be religious about using try/catch blocks and be ready with exception handling for when the user inevitably tries something stupid.
I don't know the nature of your code, so you're going to have to evaluate what's necessary on a case-by-case basis.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
That's odd.. Do you mean that after you apply a rule that deny Users to do something, a member of the very same group is still able to perform whatever it was you wanted to prevent?
|
|
|
|
|
Thanks for reply.
Yes it is allowing to delete with the rule I applied and posted here as well. I might be missing something in the rules but it is allowing.
It might be because I have admin rights on my PC.
Thanks.
|
|
|
|
|
I didn't check your use of flags that thoroughly, but it looked ok. But since you only add the deny rules for the Users group I would assume an Administrator is still able to delete the folder in question.
|
|
|
|
|
Hi guys i got a question for you:
I have created a windows mobile 6 app for a project at school. I have a docked picturebox and the sizemode is set to stretch.
I want to know how i can zoom into my picturebox on a specific area of the image. Like the double tap zoom in some windows mobile 6 applications. I tryed to use the sizemode.zoom but it isn't in there
Any help would be superb
|
|
|
|
|
Hey i dnt know the answer but u maybe got it because ur ques before 3 month plz if u know the answer provide it to me because i neeed it veeeery quickly
thx for ur help
send on this email :
ai_elhakim@hotmail.com
|
|
|
|
|
Hello,
is there any solution to use another control than the standard-WebBrowser-control which is binded by the Internet Explorer?
My favourite is the WebKit, but the Problem is, that in the .NET Wrapper for the WebKit (WebKitDotNet) isn't any way to interact with the page over InvokeScript() and ScriptableObjects and so on...
Is there any way to find a fast and modern WebBrowser-Control, which supports the interaction with the JavaScript of the page?
It would be great if there's something, which is able to run on Mono too.
Thanks for your help =)
|
|
|
|
|
Found this[^] on CP. May be useful to you.
Me, I'm dishonest. And a dishonest man you can always trust to be dishonest. Honestly. It's the honest ones you want to watch out for...
|
|
|
|
|
|
Iam developing a Desktop Based Application. Where user logins into it in Form1. I have to retrvie Information on Logged in Profile Name in Form 6, I have to get the Username in Form6. How to hold the Username, any Solution for it.
As of now iam using a text file and reading from it when required... Please Help me....
|
|
|
|
|
As I understand you are confuse with session on web. There is nothing like session in Desktop Application.
Here you can use OOP fundamental by making entiry(class) of user profile and pass reference to every form where you need it
I know this is not enough but I need more proper description.
Thanks
Life's Like a mirror. Smile at it & it smiles back at you.- P Pilgrim
So Smile Please
|
|
|
|
|
It depends on what kind of app you are producing: multi-machione, or single.
For multiple machines, the obvious solution is to use a small database, if you can install either MSSQL express or MySql on the relevant machines. If not, then consider an XML file via datasets, but be aware that you will have to cope with multi-user problems yourself, if you are using a central repository for several machines.
If it is just multiple persons login in on a single machine, and no networked connection is expected, then I would suggest the App.Config file, or in desperation the Registry.
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
I want to store Image and retrieve image From Access Database... Please Suggest the Process or else any link so that i will end u with a Solution... And more over what type of Datatype i have to take in Access DB, is it OLEDB or any other.... Thnks
|
|
|
|
|
|
A couple of days ago I asked here how to ensure that a generic list isn't modified while an operation like Find() or Exist() is performed on the list. I was recommended to use the lock-statement.
Now I would like to know if it's enough to lock the list while adding or removing items from it? Or do I need to lock it while performing a non-changing operation like Find() on the list as well?
Thanks for help!
|
|
|
|
|
Hi,
you have to use the lock-statement while adding and removing and also for non-changing operations.
The lock-statement is like a monitor (imagine a gatekeeper) that allows execution of a critical code block. So to be sure if you have several critical blocks that only one block is executed at one time you have to use the same gatekeeper for all blocks.
Example:
<br />
private Object thisLock = new Object();<br />
<br />
public void AddItem(object item) {<br />
lock(thisLock) {<br />
}<br />
}<br />
<br />
public object FindItem(object criteria) {<br />
lock(thisLock) {<br />
}<br />
}<br />
Be pay attention that all access to the list is within a lock-statement using the same object (gatekeeper).
Hope this helps a bit.
Regards
Sebastian
|
|
|
|
|
Thanks for the reply!
You're right. I did a test and tried it out. But is there some way around this? So while a non-changing operation is performed on the list other non-changing operations can get access to the list as well? So that only modifications to the list can be stopped while theese non-changing operations is happening to the list?
The reason is I'm creating a WCF service and each client contacts the service on a different thread. Each time a clients calls a method on the service the list is searched. This means if several hundreds of clients are connected every thread is locking the list and it takes some time to search there will be a real performance decrease.
A solution I guess is to wrap all non-changing operations in try-catch blocks and skip the lock but that seems like a real hack!
EDIT: It's a static list we're talking about in this case.
Thanks again!
|
|
|
|
|
Yup, this solution is a real hack. But the problem you refer to is the reader/writer problem. And guess what, the framework contains a solution for this called the ReaderWriterLock:
http://msdn.microsoft.com/en-us/library/system.threading.readerwriterlock.aspx[^]
Didn't used it myself but it seems easy to utilize.
It doesn't matter if it is a static list as long as you are using static methods to access the list (using a static monitor).
EDIT: I have to correct myself: You don't need static methods. All you have to do is using a static monitor (gatekeeper).
Regards
Sebastian
|
|
|
|
|
I found it just before I saw your answer It seems there are two solutions: ReaderWriterLock and ReaderWriterLockSlim.
It seems to exactly what I need!
Thanks for your help!
|
|
|
|
|
Iam Using 2 Threads in My Application. 2 Threads has to Update the single Progress Bar, so that user will come to know when the Process is completed. iam very nave to C# can some body help me out regarding this Please.... Thanks in Advacne.....
Or else Please suggest some Sample....
|
|
|
|