|
I have a simple C# apllication that is transfering files from one machine to another. PC's are connected via VPN. Copy(path1,path2) function works very slow - about 1% of bandwidth. What can be the reason ?
I'd be very greatful for any help
|
|
|
|
|
Hi,
are you pushing or pulling, i.e. which of the paths is the local one?
I expect performance could be quite different, with pull much faster than push,
although I never tried it.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
What happens when you normally copy files? It is any faster?
|
|
|
|
|
Hello all.
I am trying to decide if it's better to have all my classes in one .cs file within my project(for instance 'MyClasses') and then just put all my classes inside that file. This would result in code like this.
MyClasses.MyClass x = new MyClasses.MyClass():
The alternative is obviously putting each individual class in it's own .cs file under the project. This would enable me to simply do
MyClass x = new MyClass();
What is the advantage/disadvantage of doing this both ways?
I do not want to build the classes in a separate project and import the dll. So I'm really just wondering about these 2 different ways of building the classes in my project.
|
|
|
|
|
IMHO the later is better as it is easy to manage. But don't forget to use namespace[^].;P
*jaans
|
|
|
|
|
Agreed, the latter is better. No need to have a class filled with classes purely for the purposes of grouping. Just make sure they're all under the same namespace.
He who makes a beast out of himself gets rid of the pain of being a man
|
|
|
|
|
you are confusing physical .cs files with namespaces!
It is 100% preferable to stick to the one-class-per-file method.
|
|
|
|
|
I have created two instances of a class in my code but when I assign a value to a property both instances are being updated. I'm sure I must be doing something really obvious wrong, but I can't see what. Please help!
private Campaign objCampaign;<br />
private Campaign origCampaign;<br />
<br />
origCampaign = (Campaign)Session["origCampaign"];<br />
objCampaign = (Campaign) Session["objCampaign"];<br />
<br />
objCampaign.WaveCount = Convert.ToInt32(txtNbrWaves.Text);<br />
<br />
<br />
public class Campaign : IComparable<br />
{<br />
private int _WaveCount;<br />
public int WaveCount<br />
{<br />
get<br />
{<br />
return _WaveCount;<br />
}<br />
set<br />
{<br />
_WaveCount = value;<br />
}<br />
}<br />
}
|
|
|
|
|
I suspect that somewhere along the line objCampaign and origCampaign are being set equal to one another. If they are then the references (tho different) point to the same object in memory. OR something is happening in Session (whatever that is) that breaks your indexer. Why are you indexing on the variable name btw?
Scott P
"Run for your life from any man who tells you that money is evil. That sentence is the leper's bell of an approaching looter." --Ayn Rand
|
|
|
|
|
I think you're right. I have an array of Campaign objects and I am assigning the same item to both objCampaign and origCampaign. I hadn't realised that they would be stored as pointers to the same area of storage rather than having their own discrete areas. Time to think of a different approach!
Thanks for your help.
|
|
|
|
|
If your campaign objects are simple enough, you can make them structs, which would solve the problem since structs are ValueTypes and not ReferenceTypes and get put on the stack and not the managed heap. Otherwise you could make your class clonaeble, but there are some pitfalls that you'll have to watch out for depending on your class members and your clone implementation.
Scott P
"Run for your life from any man who tells you that money is evil. That sentence is the leper's bell of an approaching looter." --Ayn Rand
|
|
|
|
|
I looked into both suggestions but my class was too complicated to use structs and making it cloneable looked like overkill for what I needed. I've solved the problem by adding a copy constructor to the class which creates the new object and copies each property across from the old one.
Thanks again for pointing me in the right direction.
|
|
|
|
|
I've been trying to save the entire request.browser object to my MSSQL 2005 database. I used to save objects to a Firebird database in Java, by putting them in a blob field.
Now however, I can't seem to do it with the C# MSSQL 2005 combination. I've tried an "image" field, aswell as an "binairy(MAX)" field. I've tried serializing it (apparently the object request.browser comes from can't be serialized), and I'm basically all out of ideas.
So my question, good people, anyone ever tried this before, or has some pointers at how I could accomplish this? I'm only trying to put the object in the database, making a new object and copying all the data in there is not an option.
modified on Wednesday, April 23, 2008 12:56 PM
|
|
|
|
|
|
Hello,
i have a problem, i create a class for example for each customer, now i want to held all "customers" so the class of them in a array...
how can i do this?
it must be possible to delete objects, and add them to this array... and is that possible with arrays?
thanks
|
|
|
|
|
Arrays are ok, but better would be Generic List[^]
Read up and use that
He who makes a beast out of himself gets rid of the pain of being a man
|
|
|
|
|
Have you ever came across some thing like this[^]?
*jaans
|
|
|
|
|
Lol, beat ya to it
He who makes a beast out of himself gets rid of the pain of being a man
|
|
|
|
|
Try using a generic list. You can do all sorts of things with it.
Scott P
"Run for your life from any man who tells you that money is evil. That sentence is the leper's bell of an approaching looter." --Ayn Rand
|
|
|
|
|
HAHA Everyone jumped on this one
"Run for your life from any man who tells you that money is evil. That sentence is the leper's bell of an approaching looter." --Ayn Rand
|
|
|
|
|
Hehe yea, I like to promote the use of generic List wherever possible
He who makes a beast out of himself gets rid of the pain of being a man
|
|
|
|
|
Has anyone suggested using a list yet?
My current favourite word is: Bacon!
-SK Genius
|
|
|
|
|
I would suggest a book instead.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
I already have a book. If I buy a second book, should I keep them in an array,
or do you have a better suggestion?
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Luc Pattyn wrote: I already have a book. If I buy a second book, should I keep them in an array,
or do you have a better suggestion?
Is one of those books a Dictionary?
|
|
|
|