Question

I am working on a WinForms application which uses a flatbed scanner (in conjunction with PixTools library).

Currently when running in debug mode (unpublished), when the application code scans the image, it stores the image file .jpg in the bin folder of the project (C:...\Source\winapp\bin). My code then has to manually move this file using File.Move() to the directory where I want it to end up.

However I am thinking that when I publish the application to install on another machine, this bin folder won't exist. I am wondering where the application is likely to store the .jpg from the scanner in this case so I can write the code in advance. For instance, will the image appear somewhere in the installation folder which is selected when installing application the first time round?

Thanks for any advice/help

C

Was it helpful?

Solution

You can Create/Store your image file(.jpg) into your Debug/Release folder which is the path from where your Application exe runs.

The following code gives you the path from where your Application is running:

String  ApplicationFilePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase).Replace("file:\\", "");

The Above code returns the path similar to

SolutionFolder/ProjectFolder/bin/Debug(or)Release

So you can target your code to retrieve the image from the above location as it is avaialable even after deplyoing/Installing the Application on client PC.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top