In the Product.wxs file I used for my installer, I have a feature that creates some folders in ProgramData and adds some files to those
<Feature Id="IOFilesFeature" Title="Settings and IO Files" Level="1">
<Feature Id="Languages" Title="Languages" Level="2">
<Feature Id="Languages_UK" Title="English" Level="3">
<ComponentGroupRef Id="ProgramData_MFR_PRD_Languages_UK" />
</Feature>
</Feature>
<Feature Id="OpsPC1" Title="Operator PC 1" Level="2">
<Feature Id="OpsPC1_Settings" Title="Settings" Level="3">
<ComponentGroupRef Id="ProgramData_MFR_PRD_Settings_Ops1" />
</Feature>
<Feature Id="OpsPC1_IO" Title="IO" Level="1">
<ComponentGroupRef Id="ProgramData_MFR_PRD_IO_Ops1" />
</Feature>
</Feature>
</Feature>
<Fragment>
<Directory Id="CommonAppDataFolder" Name="ProgramData">
<Directory Id="PD_MFR" Name="CompanyName">
<Directory Id="PD_MFR_PRD" Name="ProductName">
<Directory Id="PD_MFR_PRD_Languages" Name="Languages" />
<Directory Id="PD_MFR_PRD_Settings" Name="Settings" />
<Directory Id="PD_MFR_PRD_IO" Name="IO" />
</Directory>
</Directory>
</Directory>
</Fragment>
Each file is similar to this:
<Fragment>
<ComponentGroup Id="ProgramData_MFR_PRD_IO_Ops1" Directory="PD_MFR_PRD_IO">
<Component Id="FileID" Guid="2be6ba39-9496-4985-8317-5bd0b3f88f95">
<File Id="FileID" Name="FileName" Source="SourceLocation" />
</Component>
</ComponentGroup>
</Fragment>
I noticed after using the installer that the files could not be edited by the program. Manual edits would show only in windows explorer. When I looked at the file contents after reading them from the below code the contents would not update to what I had manually changed.
public static string ReadFile(string fullPath)
{
string rv = "";
try
{
if (File.Exists(fullPath))
{
FileStream fs = new FileStream(fullPath, FileMode.Open, FileAccess.Read);
if (fs.CanRead)
using (StreamReader sr = new StreamReader(fs))
rv = sr.ReadToEnd();
}
}
catch (Exception ex)
{
ex.WriteToFile();
}
return rv;
}
I deleted the CompanyName folder from within ProgramData to see if it would allow the program to recreate the files and the program could still read the file. Windows explorer would show that the folder did not exist.
Do you know what could be causing the files to "ghost" this way?