|
Simple question.
Is there a command to copy a directory in a different path without doing this manually on files and sub-directory contained there?
I've not found any copy command on System::IO::Directory ... it's strange!
Thank you
Russell
|
|
|
|
|
If you wanna move the directory, use Directory.Move
|
|
|
|
|
No, .... sorry...I want to copy it
Russell
|
|
|
|
|
Do you want to copy subfolders too?
|
|
|
|
|
yes...like MS-DOS command xcopy does.
Of course, I can use directly that command, ... but I'm trying to understand if there is an implemented function that does this copy that I still not know.
Thank you
Russell
|
|
|
|
|
As fas as I know there is not such built-in function but if you search codeproject for xcopy you will find what you need.
|
|
|
|
|
To my knowledge, I feel you will need to iterate and copy each file.
|
|
|
|
|
You have to write you own recursive procedure...
Regards,
Shy.
|
|
|
|
|
Hello,
I think you are looking fot this[^]
All the best,
Martin
|
|
|
|
|
Another idea for you is to do a simple hack - use the Process class and start a process using the xcopy command like you mentioned in some of your other posts.
I actually have done this in a build app I wrote.
I've also used the process class for doing FTP and LPR (using the built-in Windows commands, since there are no easy classes in the framework for this).
David
|
|
|
|
|
Hi
I have already wrote about my problem. I have a string that comes from console app
after it i convert it with this procedure
static private string EncodeMessageForConsoleOutput(string Message)
{
//gag
if (MemoLog == null)
return Message;
if (EncodingFrom.CodePage == EncodingTo.CodePage)
return Message;
Decoder decoder = Encoding.UTF8.GetDecoder();
byte[] bytes = Encoding.UTF8.GetBytes(Message);
char[] chars = new char[bytes.Length * 5];//*2
int bytesUsed, charsUsed;
bool completed;
decoder.Convert(bytes, 0, bytes.Length,
chars, 0, chars.Length, true,
out bytesUsed, out charsUsed, out completed);
string ResultString = new string(chars, 0, charsUsed);
return ResultString;
}
but it does not work
Could you help me
what's the problem with this code?
|
|
|
|
|
Hello all,
how to compare two times using DateTime object. I need to compare hours & minutes only based on this i am showing some message.
plz help me
regards
GV Ramana
|
|
|
|
|
For hours and minutes only, without dates and seconds:
DateTime first;
DateTime second;
if (first.Hour > second.Hour)
{
}
else
if (first.Hour == second.Hour)
if (first.Minute > second.Minute)
{
}
else
if (first.Minute == second.Minute)
{
}
else
{
}
else
{
}
|
|
|
|
|
Hello,
Look at System.TimeSpan class.
All the best,
Martin
|
|
|
|
|
TimeSpan is what you need.
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
Yu can use the System.TimeSpan class. Quite handy, especially when used in conjunction with System.DateTime .
<br />
DateTime dt1 = DateTime.Parse("2007/06/14 13:24:00");<br />
DateTime dt2 = DateTime.Parse("2007/06/14 12:00:00");<br />
TimeSpan ts = dt1 - dt2;<br />
double elapsed = ts.TotalHours;<br />
This will give you the total number of hours elapsed from dt1 until dt2. If you are rather interested in the total number of minutes that elapsed you can use:
double elapse = ts.TotalMiutes;
or a host of others.
|
|
|
|
|
Hi,
if you want to ignore the other fields in a DateTime, you can not easily use the available
functions, nor TimeSpan.
I then suggest something like this:
public static int CompareHourMinuteOnly(DateTime dt1, DateTime dt2) {
int diff=dt1.Hour-dt2.Hour;
if (diff==0) diff=dt1.Minute-dt2.Minute;
return diff;
}
|
|
|
|
|
Ramana. G.V wrote: how to compare two times using DateTime object. I need to compare hours & minutes only based on this i am showing some message.
If DateTimeObject1.TimeOfDay = DatTimeObject2.TimeOfDay Then<br />
'do something<br />
End If
|
|
|
|
|
Hmm,
It's not an answere to the question, and it's not C# code!
|
|
|
|
|
Another way would be to force the 2 DateTime instances to have the same date (hardcode to something like 0001-01-01) and then do a DateTime.Compare(d1, d2);
-----
Formerly MP(2)
If atheism is a religion, then not collecting stamps is a hobby. -- Unknown
|
|
|
|
|
Hi,
Can any one please give me a script to browse and upload a file to a specific webserver location which should also check the extension of the file ( for eg, css files needs to go into one location and graphics files need to go into another location)
Thank You.
|
|
|
|
|
|
So I have a class for which I wrote a nice indexer, making it possible to access the class contents as if it were an array. Some like this:
public class MyClass
{
protected byte[] buffer;
protected int size;
public byte this[int index]
{
get
{
if (index<0 || index >= size)
throw new IndexOutOfRangeException();
return buffer[index];
}
set
{
if (index<0 || index >= size)
throw new IndexOutOfRangeException();
buffer[index] = value;
}
}
}
Now I'd like to pass this entire class (the array'ed version so to speak) as a parameter to a function. Say I have a function defined as follows:
public void myFunc (byte[] inbuffer)
Obviously I can't call this function as follows:
MyClass myInstance = new MyClass();<br />
myFunc (myInstance);
because it will give a compile time error of cannot convert from 'MyClass' to 'byte[]'
So even though, through the very nice functionalty of indexers, I can access the class as an array, I still can't pass it as an array. Is there a way that I'm just not aware of?
|
|
|
|
|
Dewald wrote: Is there a way that I'm just not aware of?
Not really. What is happening is all just syntactic sugar. It looks like an array but you know that it isn't really an array. Therefore, if you want it to be an array you have to convert it to one.
My suggestion would be to add a method called GetAsByteArray() or similar and the contents of the method would create and return this byte array.
Returning the internal buffer should be avoided as it would be possible for something outside your class to modify the contents and your class wouldn't know about it. That would break the encapsulation aspect of OO.
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
* Reading: Developer Day 5
Never write for other people. Write for yourself, because you have a passion for it. -- Marc Clifton
My website
|
|
|
|
|
Thanks Colin,
I was starting to think that I should probably use something like a GetAsByteArray() method but then it occured to me that it should be possible to override the implicit cast operator and would you believe!
I now have the following piece of code in my class:
static public implicit operator byte[](MyClass m)
{
return (byte[])m.buffer.Clone();
}
... and Bob's your uncle.
The reason I'm using the Clone() method of Array is so that I don't pass the array reference itself which, as you pointed out, would break the aspect of encapsulation.
|
|
|
|