This project is read-only.

FtpTrace creates empty loggfile?

Nov 9, 2013 at 7:51 AM

Got things going pretty good thanks to documentation och examples (and a little help from previous posts here...). Up and runnig with most functions I need to use, but are having problem with FtpTrace. It produces a logg-file but never with any content.
    FtpTrace.AddListener(new TextWriterTraceListener("logg.txt"));

            FtpClient link = new FtpClient();
            link.Host = "HOST";
            link.Credentials = new NetworkCredential("userid", "password");

            string wd = link.GetWorkingDirectory();

            foreach (FtpListItem item in link.GetListing(wd,
                    FtpListOption.Modify | FtpListOption.Size))

                switch (item.Type)
                    case FtpFileSystemObjectType.Directory:

                    case FtpFileSystemObjectType.File:

Above works fine, connects, retrieves listing and displays that in RTB. But the logg-file that is created is empty! I have referenced the DLL from the debug-folder in the download. Is there something I am missing?

Nov 9, 2013 at 2:50 PM
I have confirmed that the TextWriterTraceListner's work in the release and debug builds regardless of the flush property. I suspect that problem lies somewhere else. Can you provide additional information about your project?
Nov 9, 2013 at 5:24 PM
Edited Nov 9, 2013 at 5:36 PM

Well, that's pretty much it right now. Just testing the different functions and wanted to get the ftptrace-logg to logg above connection. Code-wise what you see above is what I have (yes I am fresh to this...). Any other info I can provide for you?


Dont know why but changed above to:
TextWriterTraceListener logg = new TextWriterTraceListener("logg.txt");

            FtpTrace.FlushOnWrite = true;
and ended all with removelistener and then it works like a charm!
Nov 9, 2013 at 6:07 PM
Great, I suspect it has something to do with flushing the underlying writer.
Nov 10, 2013 at 1:57 PM
Yep, retraced the changes and FlushOnWrite set to true did it!