2017-02-06 2 views
0

Visual Studioコードのローカル実行中にログを効率的に書き込む方法。'D: Users * app PublishedWebsites WebMatrixWebsite Logs'のパスの一部を見つけることができません

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); 

ここにログの配置があります。しかし、私はappharborのサーバー上で私のウェブサイトを公開するときにエラーが発生しています。そしてボタンをクリックした後、私はこのエラーが発生しています。以下は

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

スタックトレースです:

スタックトレース:

[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 

どのように私はまた、サーバー上の私のログファイルを表示するには、この問題を解決することができます。ご協力ありがとうございました。ありがとう。

答えて

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

追加の '\'に注意してください。

AppDomain.BaseDirectoryの値はバックスラッシュで終了しません。

関連する問題