Hello Friends,

I have developed a windows application using C#, its installed on

C:/program files/application folder/application.exe

I have not used Data base so i have used files (CSV/TXT) for storing data, there is many types of files generated by application and some application setting variables are also stored in a file named

C:/program files/application folder/Application Settings folder/applicationSettings.data

(encrypted Text file) application used these settings to read paths other files and some other settings, this application also have the feature to print document/images using

PrintDocument printDocumentObj= new PrintDocument();
pd.PrintPage += new PrintPageEventHandler(PrintPageEventHandlerFunc);

application prints files successfully but if I select other printer like


this also prints the document/image but after printing application can't find the application settings file which is stored in

C:/program files/application folder/Application Settings folder/applicationSettings.data

i have tried to debug the program and found that the application searching applicationSettings.data file in wrong location

\\othersystem\\Application Settings folder\applicationSettings.data 
which should be this...
C:/program files/application folder/Application Settings folder/applicationSettings.data

I am not sure why the path changes after selecting the other printer even i have have used constant variable for storing the path of applicationSettings.data

thanks in advance

5 Years
Discussion Span
Last Post by boyans

I have tried to define the path variable of ApplicationSettings.data

const string _ApplicationSettingFolder = @"C:\program files\application folder\Application Settings folder\Application Settings folder";
const string _ApplicationSettingFolder = @".\Application Settings folder";
String strAppDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase);
const string _ApplicationSettingFolder = strAppDir + @"\Application Settings folder";

All three types are not working... :(

its seems that the Application.ExecutablePath changes after selecting other printer.

Edited by katarey: n/a


If you know that printing can change the current directory just remember it
before printing and restore it after printing:

string temp = Directory.GetCurrentDirectory();
......................do whatever

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.