Click here to Skip to main content
15,919,778 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
i try this code..

C#
if (checkBox2.Checked)
              {
                  if (textBox2.Text != "")
                  {
  string filepath = "C:\\Users\\Public\\DemoManishRT_1\\DemoManishRT_1\\EXE\\setup.exe";
                    

                          Directory.CreateDirectory(textBox2.Text);
                          File.Copy(filepath, textBox2.Text+@"\");

                          System.Diagnostics.Process.Start(filepath);


                  }
              }

it execute some file here..
System.Diagnostics.Process.Start(filepath);
execute file that file are moved/copied to user folder.
here some files are moved but i think not work where i am mistake
File.Copy/Move(filepath, textBox2.Text+@"\");
this code is i mention place exe inside a folder---@"\"...
Posted
Comments
Pheonyx 4-Apr-13 4:07am    
Things to consider:

a) Does the user have the correct permissions?
b) Does the folder path exist?
c) Does the path in the text box already have a "\" at the end of it?

Are you getting any errors? if you step through your code slowly, does it work?
I also believe you have to have the file name at the end of the destination.

i.e. File.Copy(filepath, textBox2.Text+@"\setup.exe");
srigates 4-Apr-13 6:31am    
File.Copy(filepath+@"\googletalk-setup.exe", textBox2.Text + @"\googletalk-setup.exe");
System.Diagnostics.Process.Start(textBox2.Text + @"\googletalk-setup.exe");
yes friend now i got solved my problem.thanks for solutions.thanks lot.
Naz_Firdouse 4-Apr-13 4:10am    
what is the issue nw?
any errors?

Hi srigates,
here i have a solution for your error.
C#
// Below your file line that was not required, use get current directory.. and get file stored default path
and copy to file to destination where u want
//string filepath = "C:\\Users\\Public\\DemoManishRT_1\\DemoManishRT_1\\EXE\\googletalk-setup.exe";

string filepath = System.IO.Directory.GetCurrentDirectory();

// Below create folder for that particular path
Directory.CreateDirectory(textBox2.Text);
File.Copy(filepath+@"\setup.exe", "destination file path" + @"\setup.exe ");

// and below ill exeute file automatically
System.Diagnostics.Process.Start(textBox2.Text + @"\setup.exe");

I hope it will help for you.... just have a fun.
 
Share this answer
 
Comments
srigates 4-Apr-13 8:18am    
hi Gowtham,
ya i change my code to
<pre>string filepath = System.IO.Directory.GetCurrentDirectory();</pre>
its work correctly...it solve my program error what i am expexted. now i am feel free..thanks lot and keep answering ...
My solution suddenly started to not compile properly. Its attempting to copy the Exe file from the Obj directory to the Bin/Debug directory but fails.

Unable to copy file "obj\Debug\App.Client.exe" to "bin\Debug\App.Client.exe". The process cannot access the file 'bin\Debug\App.Client.exe' because it is being used by another process.

I have tried the following solutions, but without any luck:

Checked that the App.Client.exe is not in the process explorer, due to the program not shutting down correctly.
Tried to add the following to my Startup project prebuild event:
if exist "$(TargetPath)"*".locked" del "$(TargetPath)"*".locked"
if exist "$(TargetPath)" move "$(TargetPath)" "$(TargetPath)."%date:~4,2%%date:~7,2%%date:~10,4%_@_%time:~0,2%h%time:~3,2%m%time:~6,2%s%.locked

Enabled diagnostic logging (Tools->Options->Projects and Solutions->Build and Run->MSBuild project build output verbosity->Diagnostic. I will will paste some of the log concentrating on the issue in this question.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900