|
weirdsteve wrote: at least there are some kind people on here who will just even quote or tell me what i am suppose to search
The title of your thread is "C# back up program"
Google for your own title and you would get
Backup Utility in C#[^]
as the second hit (the first is your thread)
So.. you're basically learning how to use Google. Good for you.
|
|
|
|
|
erm thanks for that ..... all you people are not nice are you :S okay sorry , and i know google is quite good isn't it ? i mean you can search anything , i did actually try that result obviously and i couldn't open the .zip file on visual basic 2008 as it wasn't compatible , hence why i thought i could come here for a bit of help as i thought you were kind people and would lend a hand instead of giving a person a hard time .... but yeah google is good as you can search a word in the text box WOW !
|
|
|
|
|
weirdsteve wrote: i did actually try that result obviously and i couldn't open the .zip file on visual basic 2008 as it wasn't compatible
Then you're also in the wrong forum, batting 100% aren't we today?
|
|
|
|
|
battling ? who said i was ? i am just saying my opinion on the subject ... and no i am in the right forum .. and can't help it for visual basic c# express 2008 faults which stop me from learning ... if u are battling ... may i suggest you stop as i am just saying my opinion and only asked for a bit of help on a forum i don't know but read the terms of use and how to question ...... But may i suggest you look at how to answer a question which is
HERE![^]
and i can seriously say that the question was not in the wrong forum, not inappropriate, in perfect English but could of been poorly structured for you to understand .. so read carefully. ..
|
|
|
|
|
Batting, not battling, you must learn to read my posts, it's an expression about baseball that is combined with sarcasm to illustrate the amount of mistakes you've made in a short period of time.
Here[^] is a guide about asking a question.
|
|
|
|
|
And sarcasm , like everyone knows, doesn't work on text typed on a forum or document with nothing to suggest it is in fact how u are saying it , all i needed was nice simple help.. which would be better with a simple answer, such as .... " weirdsteve the thing you need to research on google is "c# file copying" which will direct you to the right source for your problem"
|
|
|
|
|
I would agree...
...except the phrase is ONLY used in sarcasm and has no other meaning.
|
|
|
|
|
if you say so , but if you weren't going to be helpful , then u could of just carried on ....
|
|
|
|
|
You're using C#, or VB ? I'm confused. Either way, the best way to learn, is not to look at other source code, not at first. you would do better to work through the examples in a C# book, if you're starting out. From there, you'll understand enough to read up on things like the System.IO namespace and file watchers, which is basically what you need for the task at hand ( watch a folder, when a file is created or changed, copy it to the backup folder with System.IO.File.Copy )
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
i am using visual basic c# which includes both ... anyway thanks for your suggestion
|
|
|
|
|
weirdsteve wrote:
Forum: C#
Subject: Re: c# back up program ? :S
Sender: weirdsteve
Date: Thursday, September 17, 2009 7:14 PM
i am using visual basic c# which includes both
There is no such thing. What I mean is, you're using a VB Express Edition or a C# express edition ( although you may have both installed ), and either way, you're using VB or C# in your project, not both. you should choose one and stick to it if you're learning, don't go back and forth, it will only confuse you.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
what i mean is i am using visual c# express and coding the buttons etc ... the buttons and features come from the toolbox in the designer view , then the c# comes in the coding feature ..
|
|
|
|
|
EliottA wrote: and you would get ... as the second hit (the first is your thread)
Yeah, I've noticed that too. There was a time the answer to most questions was in the first hit; Chris must have done something wrong since now the first hit usually returns a question, not an answer.
Luc Pattyn
Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
It wasn't meant to be kind. It was meant to point out how incompetent you are and that you could very easily have done this for yourself and not bothered us or shown your ignorance.
only two letters away from being an asset
|
|
|
|
|
well if u didn't want bothering , just carry on , i only asked because i didn't know what it was called ... if you don't want to share your knowledge then why the hell are you on a forum ?
|
|
|
|
|
You don't get it, telling you
back up program = copying files
is not sharing knowledge, it's encouraging stupidity.
|
|
|
|
|
obviously back up means copy , but maybe it was advanced , maybe basic , all u had to say is search this or give an example to share what you know .... i am not in the wrong here , as i asked a simple question that anyone with any kindness would think to themselves and say " well maybe i can give him a bit of help and steer him in the right direction" .... i did try and search my term of back up program but failed ...
|
|
|
|
|
Well you managed to make a lot of friends today didn't you
|
|
|
|
|
This is a common Question. I have given the code many times. Go yo Search Messages and Search for post by me and one of them there is a Code for Backup and restore.
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
I have not used foreach before but I know that the foreach method in what I am trying to do will simplify things emensely. I can adapt after I can see a example.
What I want to do is this:
I have an List<string> of 10 objects so lets call List<string> MyList
foreach (int i = <odd number=""> in MyList.count)
{
Messagebox(Mylist[i])
}
So in the above example It would output 1,3,5,7,9. How would I do this?
Another side point if foreach work not like the above example but like how my other theory is All the ODD number increments will contain "%" the percent sign. But the even values will contain only letters a-z and 0-9.
I don't want to have to do it the way I know how which is double incrementing...
For (i = 0; i < MyList.count; i++)
{
do work
i++
}
|
|
|
|
|
Foreach doesn't loop through the possible indices, but the elements itself... In your first example, you'd actually want something like:
foreach (int i in MyList)
Messagebox(i);
Assuming MyList is a list of integers... You're looping through the contents, not the indices.
In your second example, foreach wouldn't really help, as it's designed to operate on one element at a time, with no knowledge of the next one... You want a plain old "for," but the trick is to remember the syntax:
for ([initializer]; [condition]; [step])
The "step" part doesn't necessarily have to be just incrementing... You could do this:
for (int i = 0; i < MyList.Count; i += 2)
...to work with every other element in the list.
|
|
|
|
|
I appreciate everyone's help here.
To get a better Idea of what I am really trying to do is this:
I receive a path that in a string.
The path contains %USERNAME% in it.
So I need to convert the %USERNAME% to the users login name that windows identifies say "mgeorge"
So in the example c:\apple\%username%\MDB
would become: C:\apple\mgeorge\MDB
Which if I was using dos scripts this would easily work.
But I can't find a easy way of doing this conversion. If there is a simpler way please help me understand.
So I decided I could do something like this as my work around.
I would create a list...
private List<string> IO_SystemVariables()<br />
{<br />
List<string> IO_SystemVariables = new List<string>();<br />
IO_SystemVariables.Add("%USERNAME%");<br />
IO_SystemVariables.Add(Environment.UserName.ToString());<br />
IO_SystemVariables.Add("%MACHINENAME%");<br />
IO_SystemVariables.Add(Environment.MachineName.ToString());<br />
return IO_SystemVariables;<br />
}<br />
The loop thru that list to apply the changes to the string
say something like this:
private static string IO_CheckForSystemVariablePath(String MyPath)<br />
{<br />
List<string> io_SystemVariables = IO_SystemVariables();<br />
for (int i = 0; i < io_SystemVariables.Count; i += 2)<br />
{<br />
if (MyPath.IndexOf(io_SystemVariables[i], 0) > 0)<br />
{<br />
return MyPath.Replace(io_SystemVariables[i],io_SystemVariables[i + 1];<br />
}<br />
<br />
}<br />
<br />
}
Well the code should be close enough to what I was trying to do.
Since every the list 0,2,4,etc will be a variable and the 1,2,5,etc will be it's conversion I figured I would experiment with the foreach loop that I never have been able to figure out.
But if there is an even better way of handling this issue than what I have layed out I am all ears.
|
|
|
|
|
|
just as an example to in code...
Logged in Account username variable = mgeorge
string MyPath = "C:\Apple\%username%\Pictures"
string MyNewPath = Environment.ExpandEnvironmentVariables(MyPath);
the MyNewPath would return me the result "C:\Apple\mgeorge\Pictures"
is this correct if the code is exactly stated above?
I will try it.
|
|
|
|
|
Ok let me throw something else into the equasion
how would I check for if a valid variable Exists before passing the variable?
Would I do option A or B? If neither than what?
Option A)
if (Directory.Exists(Environment.ExpandEnvironmentVariables(MyPath))
{}
else
{}
Should I put option A in a try catch phrase?
Option B)
if (MyPath.IndexOf("%",0) > 0)
{
MyNewPath = Directory.Exists(Environment.ExpandEnvironmentVariables(MyPath)
}
|
|
|
|