|
Good Morning ,
Thanks.But I want not operating system read information , I want cd , floppy disk , network , partion(C,D) whichever one (folders , file) reader (product version, file version , configuration version) information ..
Can you help me ?
Thanks .
hi
|
|
|
|
|
Hi,
You can use the DirectoryInfo class to get the info of the drvie and folder and even files.
Manoj
Never Gives up
|
|
|
|
|
hi,
Yes , I can use the directory whichever file version and product version knife information ...
can you give me e-mail address? detail some formation tell
thanks
hi
|
|
|
|
|
Even after reading lots of articles about dispose, I still have some very annoying doubts...
For instance, a have an application that makes intence use of userControls. This user controls encapsulates a lot a Windows Forms Controls, and a COM object.
Doubts:
- Do I have to call dispose for every Windows Forms Controls in my UserControl's dispose?
- I've been told to use System.Runtime.InteropServices.Marshal.ReleaseComObject() to free the resources of my COM object. Is that necessery?
- I know that I shold dispose any bitmaps loaded. Does that means that I need to dispose an image of a picturebox, like picturebox1.image.dispose()? Or simply calling picturebox1.dispose() will do the job?
- What else do I need to dispose anyway? My userControl has a few arrays of strings, Colors and Images. I'm only disposing the images.
Thanks a lot
Peterson
|
|
|
|
|
I tend to rather reuse disposable objects than creating/disposing them, IMO if you dont use it frequently and seeing bad effects, then you dont have to worry about it.
|
|
|
|
|
Hello,
Here is what I know (or think to know) about disposing.
peterson@brfree.com.br wrote: Do I have to call dispose for every Windows Forms Controls in my UserControl's dispose?
No, If your UserControl is member of a parent which will be Disposed, it will automaticaly be called.
Lets say your UserControl is placed on an Windows.Form (So your Control is member of the ControlsCollection of the Form) and you call the Form.Close() method (which calls Dispose internal) you don't have to call Dispose of your Control.
If your Control is a member Variable which is removed from ControlsCollection during runtime , you will definitely have to Dispose your UserControl. But not the Controls which are Placed on the UserControl seperitaly (In fact, if they also are placed in the ControlsCollection of the UserControl).
peterson@brfree.com.br wrote: I've been told to use System.Runtime.InteropServices.Marshal.ReleaseComObject() to free the resources of my COM object. Is that necessery?
Sorry, Don't have information about that.
peterson@brfree.com.br wrote: I know that I shold dispose any bitmaps loaded. Does that means that I need to dispose an image of a picturebox, like picturebox1.image.dispose()? Or simply calling picturebox1.dispose() will do the job?
Same here, if your PictureBox is member of a ControlsCollection, you don't have to do so.
And you deffinitely don't have to dispose the "picturebox1.image".
But if you are changing the Image on runtime you will have to do so, before you add the new image.
peterson@brfree.com.br wrote: What else do I need to dispose anyway? My userControl has a few arrays of strings, Colors and Images. I'm only disposing the images.
As string and Color are not IDisposable members you will not be able to dispose them.
You should think of calling dispose, allways if you instanciate something new, because there could be a old instance of some class which has no more reference to your class and is not disposed, whcih will cause a memory leak.
What's also very important apart from calling dispose, is what you are doing in your Dispose method of your UserControl.
for example the disconnection of delegate (eventhandler)
I'm using the .Net Memoryprofiler for the analysis of my project:http://memprofiler.com/[^]
Hope it helps!
All the best,
Martin
|
|
|
|
|
Thanks for your quick answer, it helped a lot.
I'm also using a memory profiler. And I see a lot of objects listed as undisposed items. That means items that have been collected by the garbage colector whitout beeing properly disposed. This objects are Labels, Buttons, TextBox, Fonts and a few others.
I'm worried if this could cause a problem later, because my application is supposed to run 24/7.
When you say to disconnect a delegate in the dispose method, that includes even the delegates generated by visual studio, like the delegate for a click event of a button?
Peterson
|
|
|
|
|
Hello,
peterson@brfree.com.br wrote: When you say to disconnect a delegate in the dispose method, that includes even the delegates generated by visual studio, like the delegate for a click event of a button?
Good question!
The answer is no!
What you have to worry about is for instance:
You have an Usercontrol.
You have an UserManagementclass which provides an event, lets say "StatusChanged".
At startup you instanciate your management class once. This class will always be in memory till you end the program.
Then your Form will be instanciated with your UserControls on it.
This Usercontrols are getting a reference to this Managementclass in the constructor and connect the event StatusChanged (mymanagementclass.StatusChanged+=...).
In that case your UserControls Dispose method has to implement "mymanagementclass.StatusChanged-=...", otherways there would always be the reference to the Management class and the GC could not free the UserControls memory.
What you also can do to help the GC finding not referenced objects is setting them null after disposing.
In my example you could add "mymanagementclass=null" in the Dispose method of your UserControl.
peterson@brfree.com.br wrote: And I see a lot of objects listed as undisposed items. That means items that have been collected by the garbage colector whitout beeing properly disposed. This objects are Labels, Buttons, TextBox, Fonts and a few others. I would also be worried about that!
Looks like you are not Close() complete Forms which are shown with Show(), and always instanciate a new Form.
Is it possible that you are doing so?
Hope it helps!
All the best,
Martin
|
|
|
|
|
I close the forms, for sure... It's wierd... between the undisposed items it keeps acumulating 3 types of my userControls. The project has 7 other types of userControls that seems to be diposing Ok.
And this userControls that are not beeing properly disposed have labels and buttons in them. I believe that this may be the cause of the labels and buttons undisposed in the profiler's list.
I have left the application running for several hours, using DataLoad to keep openning and closing screens. Even though Memory Profiler shows an increase in theses undisposed items, the memory used by the application remains in 100MB - 120MB (reported by task manager). So it doesn't seems to have a leak, like the profiler sais. I don't know if I can trust 100% on the profiler. It´s documentation is not very clear in some poits...
Peterson
|
|
|
|
|
Hello,
Peterson Luiz wrote: And this userControls that are not beeing properly disposed have labels and buttons in them
Is there something else special about that UserControl?
Peterson Luiz wrote: Even though Memory Profiler shows an increase in theses undisposed items, the memory used by the application remains in 100MB - 120MB (reported by task manager).
Maybe the GC is able to free these memory although it is not disposed properly, who knows?;)
Peterson Luiz wrote: I don't know if I can trust 100% on the profiler. It´s documentation is not very clear in some poits...
That's true, but normaly it shows always too much because it also calculating the unmanaged resorces.
At the link I gave you, you could download a trial version of .netmemprofiler professional, which also shows the unmanaged resorces apart from .Net recorses!
I would recommend making snapshots from time to time and look for delta instances!
All the best,
Martin
|
|
|
|
|
peterson@brfree.com.br wrote: I've been told to use System.Runtime.InteropServices.Marshal.ReleaseComObject() to free the resources of my COM object. Is that necessery?
Yes!
|
|
|
|
|
Hello
I want to share a folder through coding, within a network.
Thanks
Devesh Mishra
|
|
|
|
|
Hi,
You can use the "SetAccessControl" method of the DirectoryInfo class for this purpose.
Manoj
Never Gives up
|
|
|
|
|
I have a table of data 'properties' containing
PropertyID int ident,
PropertyName varchar,
PropertyRequired bit,
PropertyType varchar,
PropertyValue varchar
I'm looking to create a BLL with a class MyProperties and an enum MyPropertyTypes
The MyPropertyTypes are Number, Text, Date, Boolean, ListFixed, ListCustom, Range
For the Number,Text,Date,Boolean only a single value is present but for the rest they can have more than one value
what is the best way to model a class/es to incorporate the properties common to all (ID, Name, Required, Type) and the properties specific to each PropertyType which can vary by both number and object type?
Thanks in advance
Mac.
|
|
|
|
|
class MyBase
{
int ID;
string Name;
bool Required;
string Type;
}
class Derived<T> : MyBase
{
T type
}
-- modified at 10:32 Wednesday 30th May, 2007
only two letters away from being an asset
|
|
|
|
|
Thanks Mark,
I'm still not sure though how I could load the classes if I don't know the type in advance?
Take the following scenario
Property 1 is a number
Property 2 is a range
MyProperty oProperty = new MyProperty(1);
if(oProperty.Type == MyPropertyType.Number)
{
//load property again?
MyNumberProperty nProp = new MyNumberProperty(1);
nProp.Value = 1;
}
MyProperty oProperty = new MyProperty(2);
if(oProperty.Type == MyPropertyType.Number)
{
//cast to the correct type?
MyRangeProperty rProp = (RangeProperty)oProperty;
rProperty.StartValue 1;
rProperty.EndValue = 100;
}
or another method, generics perhaps?
Thanks in advance
Mac.
|
|
|
|
|
wwwlicious wrote: MyProperty oProperty = new MyProperty(2);
You are creating a instance of the base class here. You create the instance of the specific type and use it. Also, when you will create a instance of the specifix type it will contain the type information.
i.e.
MyRangeProperty rProp = new MyRangeProperty();
rProp.StartVale = 1;
rProp.EndValue = 100;
rProp.type = Number //See here you need to set the type while creating instance.
Now, the instance of MyRangeProperty have all the info. Even if you cast it to base class, you will be able to access the "type" info, to decide what type of properties has been stored there.
Manoj
Never Gives up
|
|
|
|
|
Thanks Manoj,
how do I know which type to create an instance of in the first place if I start with only an ID though?
Thanks in advance
Mac.
|
|
|
|
|
See, whenever you get the info regarding which type you want, you can create that type of properties and get the values set. Why do you want to create a abstract type of properties? Sorry, but seems I am not able to understand your requirement properly.
Manoj
Never Gives up
|
|
|
|
|
ok a bit more explanation required I think. The properties apply to products, each product can have any number of properties attached to it.
The requirement is for properties to be shared for all products and strongly typed.
Each type has validation rules which are both common and specific per type
All properties must have a name
Required properties must have a valid value
Number can have a min + max numeric range along with prefixes and suffixes
Text can have max character limit, no pre/suffix
Boolean, no pre/suffix
Date, no pre/suffix, min + max date range
List, no pre/suffix, unlimited string values
Example
Product 1 has 4 properties color, weight, temperature range and optional
color is a list type
weight is a number type
temp range is a range type
optional is a boolean type
The property table has
ID Name Prefix Suffix Min Max DefaultValue
1 color Black|White|Red|Green
2 weight kg 0 9999 0
3 temp ºC -273 20000 -10|70
4 optional 1
The product property table holds
ID PropertyID Ordinal Required Value
1 1 1 1 Red
1 2 2 1 0.4
1 3 3 0 20|40
When a product is loaded, it contains a collection of Properties. the idea is to access the collection using and index and return an abstract or generic type of some kind to work with.
Hope that all makes sense. Its a bit more complex than I suggest but that's the basics.
Thanks in advance
Mac.
|
|
|
|
|
Since this sounds like a homework assignment I'll give you expand on what I've already said and let you complete it.
public class Property<T><br />
{<br />
private T m_Value;<br />
private string m_Name;<br />
<br />
public Property(string name, T value)<br />
{<br />
m_Name = name;<br />
m_Value = value;<br />
}<br />
<br />
new public Type GetType()<br />
{<br />
return typeof(T);<br />
}<br />
}<br />
<br />
Property<int> propWeight = new Property<int>("weight", 1);<br />
Property<bool> propOptional = new Property<bool>("optional", false);<br />
<br />
only two letters away from being an asset
|
|
|
|
|
Thanks Mark for your example, it's definately not a homework assignment (I wish!). I generalized the example quite a lot to hopefully explain the issue clearly.
I have looked at generics but I still can't get my head around how I could have a constructor to load a property from an ID without knowing the type in advance.
I won't have the name and value with which to load the property as in your example above, just an int ID.
<br />
Property propAny = new Property(1);<br />
<br />
Property<?> propAny = new Property<?>(1);<br />
? =
sorry if I'm missing the obvious here but I don't see how this works.
Thanks in advance
Mac.
|
|
|
|
|
You are going to have to rethink your architecture then. Other than using object for everything there is no way I know of to support all cases of unknown types.
only two letters away from being an asset
|
|
|
|
|
ok will have a think about it, I don't like the idea of using object much, seems like a hack approach but I liked the idea of having the values strongly typed each with the business rules encapsulated.
thanks for the help though, much appreciated.
Mac.
|
|
|
|
|
can anybody help me reading the elements of xml document???
Regards
sAqIb
"Our scientific power has outrun our spiritual power. We have guided missiles and misguided men."
Dr. Martin Luther King Jr.
|
|
|
|
|