簡體   English   中英

兩個應用程序讀/寫相同的文本文件

[英]Two apps reading/writing the same text file

我有一個Windows服務應用程序,它將日志寫入文本文件,然后有一個WinForms應用程序,該應用程序需要從文件中讀取相同的信息。

但是,如何在相同的解決方案中讓兩個應用程序讀取/寫入相同的文件? 兩個應用在相同的解決方案中使用共享項目,但是

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

兩者都指向不同的目錄。

對於常見路徑,請嘗試使用:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM