I am using Visual Studio 2010 and C#. I have the following code which simply writes and creates a log file:
StreamWriter file = File.AppendText("YouTube_Logfile.txt");
My program works on the system I built it.
But it doesn’t write to the log file as soon as I take it and run it on another machine. All other functionality of the program is working as expected.
I have even deleted the system.dll referrence and re-linked it to a local copy of the program, so system.dll is also being copied over.
[adding]: I don’t get any errors, just no log file created.
Thanks in advance,
Bruce
I suspect the cause is that it is creating the log file in an unexpected directory because, when it runs, that is the current directory. Your application should probably either include the directory in your path or change the current directory as appropriate.
Beyond that, you haven’t provided enough information for a definitive answer. Any time you work with files, you should have some exception handling to appropriately propagate any errors. Then you’d have some idea what is going wrong. –