directory - How to create a new folder in %APPDATA% using C++? -


I have included the IOUtils library and tried to use the CSIDL command, but it is not working ... < / P>

Here is the part of the code that it does:

  // ------------------- included in Is --------------------- #include & lt; Fmx.h & gt; # Include & lt; IOUtils.hpp> #pragma hdrstop #include "Unit1.h" #include "Unit2.h" #include "Unit3.h" // ---------------------- End - ----------------------- // ---- On the form show (Bug event: it does not make the necessary folder) ---- Zero __fastcall TfrmInicio :: FormShow (TObject * sender) {if (TDirectory :: exists ( "CSIDL_APPDATA \\ Nintersoft \\ Ninterfin")) {if (fileexists ( "CSIDL_APPDATA \\ Nintersoft \\ Ninterfin \\ Inf.nf")) {MmInfo- & gt; Lines & gt; LoadFromFile ("CSIDL_APPDATA \\ Nintersoft \\ Ninterfin \\ Inf.nf"); }} Else {TDirectory :: CreateDirectory ("CSIDL_APPDATA \\ Nintersoft \\ Ninterfin"); } }  //--------------------------------- End ------------ ------------------------  

I hope you can help me ... very much thanks XD

If you code directly from hard work in your directory path string "CSIDL_APPDATA" are not supposed to own . CSIDL_APPDATA is an ID number (specifically, 26) For example, a virtual folder that you have to solve the dynamic in the office to use the Win32 API:

< Pre> __fastcall TfrmInicio zero:: showing form (tubact * sender) {WCHR SSPETH [MAX_PATH + 1] = {0}; If (SUCCEEDED (SHGetFolderPathW (FmxHandleToHWND (handle), CSIDL_APPDATA, zero, SHGFP_TYPE_CURRENT, szPath))) {string DirPath = TPath :: combine (SzPath, L "Nintersoft \\ Ninterfin"); TDirectory :: CreateDirectory (DirPath); String Filename = Tipath :: Engagement (Dirpath, L. "Inf. NF"); If (TFile :: Exists (FileName)) mmInfo-> Lines-> LoadFromFile (FileName); }}

Alternatively, on Vista and only later, use instead of SHGetKnownFolderPath () :

  zero __fastcall TfrmInicio :: FormShow (torque * sender) {PWSTR pszPath; (SUCCEEDED (SHGetKnownFolderPath (FOLDERID_RoamingAppData, 0, zero, & amp; pszPath))) if {string DirPath = TPath :: combine (pszPath, L "Nintersoft \\ Ninterfin"); CoTaskMemFree (pszPath); TDirectory :: CreateDirectory (DirPath); String Filename = Tipath :: Engagement (Dirpath, L. "Inf. NF"); If (TFile :: Exists (FileName)) mmInfo-> Lines-> LoadFromFile (FileName); }}  

Alternatively, instead of retrieving the value of Sysutils :: GetEnvironmentVariable () using % APPDATA% use a CSIDL or KNOWNFOLDERID :

  void __fastcall TfrmInicio :: FormShow (TObject * sender) {string DirPath = TPath :: Combine (Sysutils :: GetEnvironmentVariable (L "APPDATA"), L "Ninersfift \\ Ninterfin"); TDirectory :: CreateDirectory (DirPath); String Filename = Tipath :: Engagement (Dirpath, L. "Inf. NF"); If (TFile :: Exists (FileName)) mmInfo-> Lines-> LoadFromFile (FileName); }  

Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -