|
-
Oct 1st, 2006, 08:31 PM
#1
Thread Starter
Member
Edit my code plz
Code:
System.IO.File.Move(@"ConsoleApplication2.exe", @"C:\windows\ConsoleApplication2.exe");
Is there a way to make it only do this if there isn't a "ConsoleApplication2.exe" in
"C:\windows\" ? Because right now, it keep doing it which makes it to shutdown. Thanks.
-
Oct 1st, 2006, 08:53 PM
#2
Re: Edit my code plz
Code:
if(System.IO.File.Exists(@"C:\windows\ConsoleApplication2.exe") == false)
{
System.IO.File.Move(@"ConsoleApplication2.exe", @"C:\windows\ConsoleApplication2.exe");
}
But I will say, write the whole path instead of just [ConsoleApplication2.exe].
-
Oct 1st, 2006, 09:32 PM
#3
Thread Starter
Member
Re: Edit my code plz
Thanks, but wat u mean by:
But I will say, write the whole path instead of just [ConsoleApplication2.exe].
-
Oct 1st, 2006, 09:36 PM
#4
Re: Edit my code plz
 Originally Posted by Visionary
Thanks, but wat u mean by:
Nothing, sorry to bother you with my idiocy.
-
Oct 1st, 2006, 09:41 PM
#5
Re: Edit my code plz
 Originally Posted by Harsh Gupta
Nothing, sorry to bother you with my idiocy.
I don't know why the change of mind , you are right!!
You must include the full path of ConsoleApplication2.exe So if the user moved the file (the current file) and tried to run it, it won't throw an exception in his face
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Oct 1st, 2006, 10:18 PM
#6
Re: Edit my code plz
 Originally Posted by ComputerJy
I don't know why the change of mind  , you are right!!
You must include the full path of ConsoleApplication2.exe So if the user moved the file (the current file) and tried to run it, it won't throw an exception in his face
You are right, writing full path is a good practice, but if the exe (or any file) is located where your application is, then full path is not required.
-
Oct 1st, 2006, 11:00 PM
#7
Re: Edit my code plz
In that case it would be,
Code:
Application.StartupPath + "\\ConsoleApplication2.exe";
But you also won't need doing this
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Oct 1st, 2006, 11:14 PM
#8
Thread Starter
Member
Re: Edit my code plz
I got it to work with Harsh's post. Thanks! No more questions on this.
-
Oct 2nd, 2006, 10:26 AM
#9
Re: Edit my code plz
 Originally Posted by Visionary
I got it to work with Harsh's post. Thanks! No more questions on this.
You can mark the Thread resolved from the "Thread Tools" menu
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Oct 3rd, 2006, 10:14 PM
#10
Re: Edit my code plz
 Originally Posted by ComputerJy
You can mark the Thread resolved from the "Thread Tools" menu
Please do.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|