|
I am creating an MDI database-driven app in WinForms (VB .NET 2003).
There are many objects that I would like to have available / around to all child forms for the life of the application:
- DatabaseProviderFactory
- Connection String
- ResourceManager object
- A custom message handler object
- etc,etc.
I figured during the mainform (MDI) load, I would create / instantiate these objects and put them in public shared properties of the main form. The child forms would reference the main form properties for their objects.
Is this considered "bad practice"? Is there a better way to do this?
Thanks,
-Len Miller
"If I had eight hours to chop down a tree, I'd spend six sharpening my axe."
-Abraham Lincoln
|
|
|
|
|
Rather than tying everything to the main form, a better solution may be to either
* design each of these objects as Singletons[^], or
* just use shared methods, so that you do not need a specific object instance.
my blog
|
|
|
|
|
Steve,
Hmmm, interesting. I will investigate the Singletons concept more - maybe that is my answer - I need to educate myself a bit on that.
I do not think the shared methods concept will work (If I understand you correctly), because these "global" objects really need to be object instances.
For example, my custom message object contains a dialog form, properties that control the "mailto:" text behind a "Contact Tech Support" link label, the icon / logo, the buttons (yes, no, cancel, etc), the existance of a "<< Details" button, etc. This really can't be handled in a shared method (I don't think). Now, the connection string can, maybe the ResourceManager object can...
Thanks a bunch for your reply Steve!
Any more wisdom or ideas you can toss me is always appreciated.
Thanks,
-Len Miller
"If I had eight hours to chop down a tree, I'd spend six sharpening my axe."
-Abraham Lincoln
|
|
|
|
|
how can I edit a textfile from vb.net. Ex I want to make a button and a textbox and when the user input data in the textbox he can enter on the button and the data from the textbox will be transported in the textfile. now i have another button and a textbox. and i want to write the input of this textbox in the same textfile under the first line i used for the previos textbox.
Then how can i read the second line of the textfile from vb.net??
Adrian
|
|
|
|
|
I am unsure what you are trying to accomplish and why, but here are some possible solutions.
When you use a text FileStream, you can use FileMode.Append to append to the text file after all the existing text quite easily.
If you actually mean that you want literally 1 line of text from textbox1, then "insert" the text from textbox2, then the rest of textbox1, then you will have to do something else.
You may create a new file, read 1 line of text from the first file, write it to the second, then write the textbox2 data, then the rest of the first file.
(yuk)
Or, you can tread the file as a rendom access file, and read/write specific bytes (fields) and limit the sections of text to "n" number of bytes.
(better?)
Or, you really may want to tread these as data tables and save to XML, or keep this data in objects and serialize the objects to XML files. it all depends on what the end-goal is.
Thanks,
-Len Miller
"If I had eight hours to chop down a tree, I'd spend six sharpening my axe."
-Abraham Lincoln
|
|
|
|
|
Hi,
I have a server that users connect to for access to their files. I also have an application that will move certain files to tape and leave a stub file with the Offline attribute behind.
Today the only way the user could get the files back is if I restore the files from tape to the server.
I would like to know a way that when a user opens an offline(stub) file it triggers a command on the server to restore the file. But at the same time have the application wait for the Offline file to be restored before opening.
Does any one know how to accomplish this?
Thanks,
|
|
|
|
|
There is no built in support for this in Windows... yet...
Since opening a file does not execute the stub you left behind, this would require an extension to the file system. Warning: Not for the faint of heart, weak in COM skills, or lacking in C++ programming.
But, you have a different problem. Since restoring from tape can take an exessively long time, you don't have control over the application to keep it from timing-out the file operation on it's own, if it has such a mechanism built in. You also don't have control over the user getting sick of waiting for it to open and clicking the close box and having the application killed off or Explorer shutdown.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Zenly,
I don't think that would be too hard to accomplish, The Net Framework has a class called:
System.Collections.Queue
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemcollectionsqueueclasstopic.asp
You could Queue the stub files, then send a message to your users that it is in a queue and will be restored, then send it to your tape backup queue, retrive the file, then send an email to your users with a link to the file location you restored it to.
I don't have a lot of free time to code something like this out, but it may give you an idea of where to go with it.
progload
|
|
|
|
|
I would realy like to make it transparent to the users so that when they open the stub file it automatically starts restoring the file. I am not sure if queuing is the best solution in this case.
I know with other HSM products the code is only installed on a server. Users who has a share on this server does not have to install any code on their desktops to be able to activate the restore. They just need to open the stub file on the share they are mapped to and the restore starts.
I am not concerned so much about the user application timing out as long as the restore starts.
I tried using the Filewatcher class to sit on the server and watch for accessed stub files but I find that if I open a file it's accessed time does not always change and filewatcher does not trap it. Any ideas why that may be?
|
|
|
|
|
No, I haven't seen that problem, and I use use it.
I have seen the buffer overflow problem mentioned on msdn, but as far as I know, the buffering problem still triggers an event in my case anyway.
See the Notes Section above the example:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemiofilesystemwatcherclasstopic.asp
hope that helps,
progload
|
|
|
|
|
I did a Google on that problem and I only found a few references, if it was fixed by a service pack or whatever I've not found anything about it. But, like I said, I haven't seen mine do it.
I do have server 2003 all up-to-date.
here's a reference to that problem:
http://www.devnewsgroups.net/group/microsoft.public.dotnet.framework/topic1649.aspx
|
|
|
|
|
I didn't say the extension had to be installed on the client.
You really don't have a choice here. The FileSystemWatcher class only triggers events well after they have occured, not during the occurance. It also gets slower and slower at triggering events the bigger the directory tree you want to it monitor. Try having it monitor your entire C: drive and watch what happens...
Now, you CAN put a stub in place of the file, but when the client double clicks the file, it's the CLIENT that runs the stub code, not the server. Since the client knows nothing of the tape backup system and will most likely NOT have rights to it at all, you've got a huge problem. This is only solvable by code running on the server and the only time this code will get executed is when the file system get an Open request and follows the installed chain of extensions.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I found an article that talked about HSM reparse point. It deletes the content of a file and creates a reparse point(stub) in it's place. When the application opens the stub it does not know any different. Are you familiar with this and how to create it in code?
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnw2kmag00/html/ntfspart1.asp?frame=true
|
|
|
|
|
Reparse Points[^]
Yes, I'm familiar with the concepts. No, I haven't written any code for it.
What you're looking for is the Windows Installable File System (IFS) Kit. It has everything needed to write a reparse point filter driver for NTFS. Since your writing a kernel mode driver, you really can't use VB.NET or any of the managed languages to do it. It is HIGHLY (can't stress this enough!) recommended to use C++ to write this...
Windows Installable File System Kit for Windows 2003 SP1 and below[^]
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks
I will try to find a c++ programmer to help me with this.
|
|
|
|
|
i have an access file with on table and 3 fields (ID, name, image) and datatype for image feild is ole object. i want to store the image as a n Encrypted image or even converted to a binary. so i want to create a vb.net project that add images and store them in the database as an Encrypted image(binary).could anyone help me on this.
|
|
|
|
|
You can get the data from an image, just specify the format. Then you can encrypt that, if you like.
|
|
|
|
|
Singapore? What are you doing in Singapore?
Vacation? Please tell me you're not on CodeProject in the middle of a vacation?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
|
With what?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=3412&lngWId=10
|
|
|
|
|
can anyone post any code to validate email address and web address... i need help here... ^^ thank you
|
|
|
|
|
There are examples of using Regular Expressions all over the 'net for validating the format of an email address. An example of which you can find here[^] on CodeProject.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi to all.
Please help me. I have to connect an autorefractor machine with my medical software so that the readings directly comes into my software and get stored in my database. i donot know where to start can anybody give me a hint. my platform is visual basic 6. and mysql .
any help will be highly appreciated.
thanks
Monica
|
|
|
|
|
I may be able to give you a hand.
Normally, the data is aquired thru the PC's serial port to the autorefractor own PC software.
You'll need to specify the brand and model of the autorefractor and if or what software you have for it, And I'll see what I can dig up about it.
progload
|
|
|
|