|
Message Closed
modified 23-Nov-14 6:39am.
|
|
|
|
|
Thank you for your answer but it's not working.
|
|
|
|
|
Hi could someone point me in the right direction to solve this problem - I am a beginner on C#, I just need to add,amend or delete items in a combobox at runtime, using the basic string collection editor that I used at design time to add items.
Many thanks
Stevemodified on Friday, March 5, 2010 7:46 AM
|
|
|
|
|
The CollectionEditor control used in the design environment to modify the collection times is design specific, and and such I don't think you can display it at run time. You will probably have to write your own editor. 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 write one user control to show server panel in the form as the control, TNotebook in Delphi.
User can select which one page as current Page.
But in the IDE, after adding the page in the collection editor, and then close the colloection editor, the page added can not see in the collection editor.
I guess that I need to write my collection editor, how can I do it?
|
|
|
|
|
Message Closed
modified 23-Nov-14 6:39am.
|
|
|
|
|
I want to use the C# to design that user control.
|
|
|
|
|
Google results for "C# user control in VB6[^]" I know, "But I'm not using VB6!". You're not, but you ARE using a language that can consume COM classes.
|
|
|
|
|
Situation:
There's a text-file, say mytextfile.txt, and it's opened by a process.
Lets say that it's unknown which process locked the file.
How would I go about getting the process that locked said file.
So simply put, I want to get the process-name of the process that's locking mytextfile.txt.
I've seen this question posted all over the net, without people actually giving good answers.
What I see a lot, is people debating the validity of the question.
The validity of the question is not up for debate, the question and the answer to it, are.
So please, if you have any concrete advice or code samples, share them with me.
If you want to debate why I'm asking this question or the validity of my question, don't bother.
Because I'm certain there's a world of developers out there who would love to know the answer as well.
|
|
|
|
|
Some niche stuff is written here: Listing Used Files[^]
And yes, you may have to use some of those esoteric API calls with p/invoke.
The idea would be to enumerate all the processes first, and then enumerate resources locked by each process individually, while looking for a match.
Hope that helps. Let me know if you have troubles.
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
I'm very much inclined to agree with you.
My searches have led me to this page already.
I'm starting to believe I'll have to delve in to this in order to get what I need.
Perhaps WMI offeres an entry point to my dilemma?
I've only quickly glanced at C# in combination with WMI.
I've done WMI with VB6 before, but don't know how to go about it in C#...
|
|
|
|
|
Some obscure API call no doubt. You'll probably need to iterate through processes or something.
Here's an article with source code that does it, although it's C++, it may give you some pointers.
http://www.kartmann.org/freeware/WhoSLocking/ReadMe.htmRegards,
Rob Philpott.
|
|
|
|
|
C++ may give you some pointers?
|
|
|
|
|
Ta-Dah! Regards,
Rob Philpott.
|
|
|
|
|
Björn T.J.M. Spruit wrote: What I see a lot, is people debating the validity of the question.
The validity of the question is not up for debate, the question and the answer to it, are.
This is because most people don't understand what's going on. They just want to close that handle and don't think about what the impact would be on the application that has the file open, nor do they consider that they are possibly corrupting the contents of the file they are, themselves, trying to modify. It is very rarely ever a justifiable, nor supportable, course of action.
By "supportable", I mean that the outcome of the operation is not 100% predicatable and therefore not something you want to do in a production application.
|
|
|
|
|
Of course... there's always one that can't resist...
Fine, I'll indulge you:
I want to give someone the ability to see which process is locking a textfile.
There's a reason they want to know and I'm not inclined to debate their need to know.
Honestly... I don't care why they want to know.
They know not to go shutting down running processes willynilly, so that's not a concern.
Actually, whatever it is they want to do, from the point where they know which process is locking the file, isn't my concern.
What IS my concern, is to provide the very basic functionality of showing them which process is locking the file.
Lets hope this rant discourages anybody else that feels the need to debate the question or the validity of it.
Unbelievable that you didn't pick up the 'hint':
The validity of the question is not up for debate
Alrighty ?
|
|
|
|
|
Wowow relax, you could just ignore him you know
I also went out of my way to look for a solution, but it is indeed hard to find - I eventually found some highly obfuscated C code that is "supposed to" do what you want.. but the links given earlier are probably better anyway.
|
|
|
|
|
You'll have to excuse my snappy reaction before, but I want to shoot down a spin-off debate on this topic on 'the validity of it all' before it gets a chance to start.
I reckon you're right on the earlier links however.
Unless someone has some knowledge on my WMI + C# question I posted as a reaction to said post.
Fingers crossed.
|
|
|
|
|
I didn't have a problem with what your question was.
I was just saying why you see that discussion all over the web and noone really answering the question.
|
|
|
|
|
Fair enough.
And it's something I see more often.
But it's not up to others to decide the validity of the question.
A question was asked, why not answer it and then ask why someone is asking it, if one is truly interested?
I can understand why some would feel frustrated with the ivory tower some developers are hiding in.
The relevance of a question can only questioned by the one asking it, imo.
|
|
|
|
|
The reason there is always a debate on why this is a valid question, in my opinion, is that 90% of the time it is the programmers actual program that is holding onto the file by not disposing of its resources before trying to delete the file.
So when your users want to know what is locking a file, are they going to see that it is another part of your code?
|
|
|
|
|
I see your point.
Though, you'd get to the same point when a developer finds out, that the process it returns, is the one the developer is debugging or has built.
It's much more effective if a developer is forced to assume responsibility for oneself,with the shaming conclusion that the developer in question needs to kick one's own behind.
My point being, give what is asked for and engage in conversation as to what the context is.
It'll result in a more social event that way.
And as to answer your question, I think that what the user is going to see, is that they still have something like Ultra Edit/Notepad/etc... is still holding the file and they forgot to close the text editor before testing/running their application.
If the question is:"Is it likely to be something silly?", the answer is most likely yes.
In the end, however, that's besides the point.
I'd prefer they'd find out for themselves in an easy way, instead of them having to bother me.
I'm all for self-reliance.
|
|
|
|
|
Björn T.J.M. Spruit wrote: Though, you'd get to the same point when a developer finds out, that the process it returns, is the one the developer is debugging or has built.
Why have that developer (who can't figure out his own app locked a file) go through the pain of writing another app he doesn't understand just to find out he screwed up in his original app?
Björn T.J.M. Spruit wrote: I'd prefer they'd find out for themselves in an easy way, instead of them having to bother me.
Most of the people who are asking the question don't have a clue about what they're doing, let alone have the ability to teach themselves anything.
Björn T.J.M. Spruit wrote: I'm all for self-reliance
Björn T.J.M. Spruit wrote: I'm all for self-reliance.
So am I. Too bad this business has been overrun by idiots who couldn't teach themselves how to use Notepad let alone how get to Yahoo or Google and do any kind of research whatsoever.
|
|
|
|
|
That is why I stopped asking questions on the Internet. Too many people who don't have the answer feel inclined to respond without realizing all they are doing is wasting someone else's time. Of course, I am doing that right now since I don't have the answer either but I am at least self-aware making me an A**hole and not a moron.
|
|
|
|
|
Do you know what, ive pretty much stoped answering questions on the internet for exactly the opposite reason - people get uppity when you actually question why they are trying to do something one way when there is a reason we don't generally do it that way.
|
|
|
|