Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create Exe and appropriate folders!?

Status
Not open for further replies.

FOR111

Programmer
Sep 29, 2005
103
MT
Hi All,

This may sound as a silly question..but it seems i can;t figure out the appropriate way of doing it.

So i have built a small system..and it needs a particular folder with its contents to work. How can i, whilst debugging or creating a release, copy these folders together with the executable itself!?

Thanks
Nick
 
Make a Setup Project that will install the EXE and all the supporting folders and files that are needed. You can specify every thing in the File System of the Setup file project.
To view the file system, right click on the SETUP Project in the project view and choose file system. This is where you tell the setup.exe to install the exe, shortcuts and supporting files in whatever locations you want.

Or create a custom installer that is more lengthy.

If you want the files and folders to be created at runtime you can use...

For Directories Creation and handling

System.IO.Directory

For New File Creation and handling

System.IO.File
 
Hi gplusplus..thanks for the advice...much appreciated!

That should work great for the deployment part..i was mainly concerned on the debugging part..when i hit F5 .. i would like that my external files are copied to the DEBUG folder too!

Thanks
Nick
 
So then use System.IO to do so on load of the main form

Code:
string file_name = @"thisTestFile.txt";
string source_path = @"c:\";
string destination_path = @"C:\Documents and Settings\Laptop\My Documents\Visual Studio 2005\Projects\MyProject\MyProject\bin\Debug\";

void form_Load(object sender, EventArgs e){

try{
    File.Copy(source_path + file_name, destination_path + file_name);

 }
catch (Exception pe)
{
   MessageBox.Show(pe.Message);
}

}
 
Hi,

On each file, right click to view the properties. Change the...
- "Build Action" -> "Content" (useful when packaging)
- "Copy to Output" -> "Copy if newer" (copies to debug/release folder)

If you put these files in a folder in the Solution Explorer, the folder is created too on the output folder after compilation.


[wink]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top