reply to gettempath() threads  
Author Message
xird





PostPosted: Visual C++ Language, reply to gettempath() threads Top

Hi , thank you for all your replies, they hve all been useful for my understanding, of what is involved.

I am the stage of being able to create a dir (c:\\TempDir) and copying files in my VS2005 project folder.

This works fine when debugging, and release to produce the .exe,

But when i test exe on clean machine, error message states it cannot locate any of the resource files. I have tried adding these to the resource folder using solution explorer (right click and add resource), the file name appears in solution explorer but not in solutions explorer resouce folder.

My question is:1. How do I save or process files in the winforms application, which I want the .exe to install/copy , when the .exe is launched.
My question is:2. Here a temp directory is created BUT not all user might have right to create the temp dir, is there a method to get around this Is it possible to give a small snippet in c++


// Specify the directories you want to manipulate.
DirectoryInfo^ di = gcnew DirectoryInfo("c:\\TempDir");
// create the directory.
di->Create();

// get temp dir path and copy resource files

// copy resource_file_1
String^ path1 = "resouce_file_1";
String^ path2 = ("c:\\TempDir\\resource_file_1");
File::Copy( path1, path2 );
// copy resouce_file_2
String^ path3 = "resource_file_2";
String^ path4 = ("c:\\TempDir\\resource_file_2");
File::Copy( path3, path4 );



Visual C++11  
 
 
einaros





PostPosted: Visual C++ Language, reply to gettempath() threads Top

My question is:1. How do I save or process files in the winforms application, which I want the .exe to install/copy , when the .exe is launched.

Which files is it you want to save Are they bundled with your .exe in a .zip or similar


My question is:2. Here a temp directory is created BUT not all user might have right to create the temp dir, is there a method to get around this Is it possible to give a small snippet in c++

You should never create your own temp folder. Use one of the folders which are already provided for that cause. There's a codeguru article at http://www.codeguru.com/cpp/cpp/cpp_managed/nfc/article.php/c9255/ which demonstrates the use of these folders. The article is written for Managed C++, not C++/CLI -- but the core of it should be the same.



 
 
xird





PostPosted: Visual C++ Language, reply to gettempath() threads Top

Thank you for the reply, in answer to your question.

"Which files is it you want to save Are they bundled with your .exe in a .zip or similar "

The files I want to save are a mixture of exe, ico, .txt , which the application.exe requires. Currently, they are located in the projects folder of the application, along with other application files. All i want to do is use the .exe to copy these files to a folder when launched. I suppose my real lack of knowledge is not knowing how to bundle these files as an integral part of the compiled exe. At the moment my application compiles and debugs, but when launched on clean machine, gives message that the files to be copied cannot be located. How do I "bundle" them to the compiled exe

Secondly, I am going through these articles as advised, and will stick with my original idea of creating a folde to copy files to, and deleting the folder when application is closed, thank you.

regards

xird


 
 
einaros





PostPosted: Visual C++ Language, reply to gettempath() threads Top

The best approach would be to make a setup for your application. Wrapping the resources inside the main .exe makes for a lengthy and tiresome process, which I fear is still a bit ahead of it's time in your learning process (absolutely no disrespect intended, just a friendly advise). If you go for a setup app, this should copy files (.exe and all additional resources) to a common folder, and allow your app to be launched from there -- with access to all the data it needs. Have a look at http://www.simple-talk.com/dotnet/visual-studio/getting-started-with-setup-projects/ for an introduction to the Visual Studio setup projects.

Creating your own temporary directory is very bad practice. Imagine what the system would look like if all applications installed did this at their own will. The result is likely to be that people shun your software .. not a good thing, I'd imagine.