Created
January 15, 2013 14:23
-
-
Save xoofx/4539007 to your computer and use it in GitHub Desktop.
Tracking read and write files by current process using FileTracker available from Microsoft.Build.Utilities.v4.0 assembly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.IO; | |
using Microsoft.Build.Utilities; | |
namespace TestFileTracker | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
// Add Reference the assembly Microsoft.Build.Utilities.v4.0 to your project | |
// Output dir and prefix for logs | |
var outputDir = "mytest"; | |
var outputFilePrefix = "mytask"; | |
// Start tracking all file access from this process | |
FileTracker.StartTrackingContext(outputDir, outputFilePrefix); | |
// Read and Write files | |
File.WriteAllText("file.txt", "YES!!!!!!"); | |
var test = File.ReadAllText(@"..\..\FileTrackerTest.cs"); | |
// Write the logs to "mytest\mytask.read.1.tlog" and "mytest\mytask.write.1.tlog" | |
FileTracker.WriteContextTLogs(outputDir, outputFilePrefix); | |
// End tracking | |
FileTracker.EndTrackingContext(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment