简体   繁体   中英

Two apps reading/writing the same text file

I've got a Windows Service app that writes a log to a text file, and then I've got a WinForms app that needs to read the same information from the file.

But how can I get both apps (in the same solution) to read/write the same file? Both apps' use a Shared project in the same solution, but the

System.AppDomain.CurrentDomain.BaseDirectory + @"\log.txt";

for both points to different directory.

For a common path, try using:

string folderPath1 = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
// or 
string folderPath2 = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM