0

I am writing the Log files in txt using some method and logs are written efficiently during local running of visual studio code.

C:\Users\ARSLAN\Documents\Visual Studio 2015\Projects\ApplicationCheckCrone\ApplicationCheckCrone\Logs

string logFilePath = "Log-" + System.DateTime.Today.ToString("MM-dd-yyyy") + "." + "txt";

            logFileInfo = new FileInfo(logFilePath);
            File.AppendAllText(AppDomain.CurrentDomain.BaseDirectory + "bin" + logFilePath, strLog);

Here are the logs placement. But i am getting error when i publish my website on server of appharbor. And after click the button i am getting this error.

Could not find a part of the path 'D:\Users\apphb113ae29dc16698\app\_PublishedWebsites\WebMatrixWebsite\Logs'.

Below is the stack trace:

Stack Trace:

[DirectoryNotFoundException: Could not find a part of the path 'D:\Users\apphb113ae29dc16698\app\_PublishedWebsites\WebMatrixWebsite\Logs'.]
   System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +366
   System.IO.FileSystemEnumerableIterator`1.CommonInit() +268
   System.IO.FileSystemEnumerableIterator`1..ctor(String path, String originalUserPath, String searchPattern, SearchOption searchOption, SearchResultHandler`1 resultHandler, Boolean checkHost) +434
   System.IO.Directory.GetFiles(String path) +70
   ApplicationCheckCrone.LogsData.BindData() +91
   ApplicationCheckCrone.LogsData.Page_Load(Object sender, EventArgs e) +24
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +51
   System.Web.UI.Control.OnLoad(EventArgs e) +95
   System.Web.UI.Control.LoadRecursive() +59
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +678

How can i solve this problem to show my log files on the server also. Thanks any help would be highly appreciated. Thanks

1 Answers1

0
File.AppendAllText(AppDomain.CurrentDomain.BaseDirectory + "\bin" + logFilePath, strLog);

Note the additional '\'.

AppDomain.BaseDirectory's value does not end with a backslash.

Zardify
  • 23
  • 1
  • 6