Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where will the file without path get created in client system

Tags:

c#

.net

winforms

I have the following code in an Winform Application

 String[] lines = { "LAST MESSAGE", "101" };
 File.WriteAllLines("MPP_Config.txt", lines);

On my Development system, the file gets created under Bin\Debug...

Where will the file be created in the client once it is installed in the client system ?

I deploy to a website using Click once Deployment...

like image 450
The King Avatar asked Feb 26 '23 22:02

The King


2 Answers

I believe it will be created in current working directory of the application. The application might not have access to this directory, especially on systems with UAC, Vista and windows 7. You should probably think about using the application data directory instead.

String[] lines = { "LAST MESSAGE", "101" };
String fileName = Path.combine(System.Deployment.Application.ApplicationDeployment.CurrentDeployment.DataDirectory,"MPP_Config.txt");
File.WriteAllLines(fileName, lines);
like image 175
Sam Holder Avatar answered Mar 02 '23 14:03

Sam Holder


I'm guessing it gets created in the debug folder becuse you have been running it in debug mode. If you ran it in release mode then it will be saved in the bin/release folder.

In other words it will be created in the directory in which the application resides. Why not try it? I.e. copy your exe across...

like image 31
James Wiseman Avatar answered Mar 02 '23 14:03

James Wiseman