Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating and using c# Application Folder

I am creating an application that uses photos and an XML file all in one folder that I am creating manually, I want to let the user update the data of that folder (Adding Photos, and Editing the Xml file) at run time via the application my question is what is the best approach and where to put that Folder, I know I have to put that relative paths so I am confiused is it in the AppData if so how to do it.

like image 912
Ahmed HABBACHI Avatar asked Jan 11 '23 09:01

Ahmed HABBACHI


2 Answers

// Use this to get the common directory
string CommonDir = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);

// And combine it with your own. 
// On Window7 this will return "c:\ProgramData\YourCompany\YourProduct"
string YourDir = Path.Combine(CommonDir, @"YourCompany\YourProduct");

// And create the directory / ensure it exists
System.IO.Directory.CreateDirectory(YourDir);

There are other Special Folders you can get from the system, such as MyDocuments or Desktop as fits your needs best.

like image 85
noelicus Avatar answered Jan 21 '23 14:01

noelicus


first right click on your project explorer and add new folder, it displays empty folder and you put this files into it.

like image 43
Datta Avatar answered Jan 21 '23 16:01

Datta