0

I have a windows form program currently outputting to my desktop, It is a windows form that outputs a HTML. I understand I can change the Output directory using visual studio in the way described here

However I want to code in an output path that will override any Visual Studio settings. Something along the lines of...

outputPath = [path/string]

I've tried searching for this but all I can find is how to do it using visual studio.

I want to avoid using FolderBrowserDialog or SaveFileDialog as they promt the user to select a path, which is not what I want.

AaronParkes
  • 313
  • 5
  • 15
  • 2
    Where do you want that code (and why)? The path is stored in the project file, it would be meaningless anywhere else – Alex K. Dec 02 '15 at 13:33
  • 1
    The link you reference is for the output of *building* the application (i.e. where the .exe goes), but it sounds like you are asking about *output from the program* (i.e. where it writes/saves files). These are two very different things. – crashmstr Dec 02 '15 at 13:39
  • Output from the program. – AaronParkes Dec 03 '15 at 09:58

2 Answers2

0

Guessing that you'd like to change the output directory of one of the things your code generates.

Perhaps this is what you are searching (Enviroment.SpecialFolder): https://msdn.microsoft.com/en-us/library/14tx8hby(v=vs.110).aspx

Implementation sample: C# Get Special Folder

Or if you'd like a different path you can set it like this:

string path = "C:\\Example\\V1\\file.txt";
Community
  • 1
  • 1
usselite
  • 846
  • 7
  • 24
0

By default a program is writing files into its current working directory (if you do not set a path information while creating the file).

If you want to write to a different directory you can either set the filename with a path included (see answer by usselite).

Otherwise you can use the Directory.SetCurrentDirectory method to change you current working directory of the program.

Hope it helps.

JokoFacile
  • 143
  • 5