Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
2.3k views
in .NET FTP by (140 points)
Hello,
I am using edtftppro for C#.NET and uploading multiple files. Since the files from the local directory have to be uploaded to certain directories based on the date-time stamp of the files, I can't use the BeginUploadMultiple() method. So, I have to loop through the list of the files, get the datetime of the files and then upload them individually using BeginUpload(). In this process, I am facing 2 problems:

  1. Is there a way to create subdirectories using one command on the fly ? Like, if I am putting File1.txt with creation date of Dec 02, 2006, I want to put it in the directory "/MyDir/2006_Dec/12_02_2006/", so I want to create "/MyDir/2006_Dec/12_02_2006/" on the fly.

  2. Since I haven't figured out a way to do the above, I am creating each of the subdirectories individually, then changing the working directory and finally putting the file. The program freezes when I issue ChangeWorkingDirectory() command. Looking at the Log file, I see the following:
    DEBUG [AsyncProcessor] 3 Dec 2006 11:38:56.934 : Queuing FTP task UploadFile(String="C:\temp4\File1.txt", String="/Upload/MyDir/2006_Dec/12_03_2006/File1.txt")
    DEBUG [AsyncProcessor] 3 Dec 2006 11:38:56.934 : Starting FTP task processor
    DEBUG [AsyncProcessor] 3 Dec 2006 11:38:56.934 : Running FTP task UploadFile(String="C:\temp4\File1.txt", String="/Upload/MyDir/2006_Dec/12_03_2006/File1.txt")
    DEBUG [AsyncTask] 3 Dec 2006 11:38:56.934 : Running task: UploadFile(String="C:\temp4\File1.txt", String="/Upload/MyDir/2006_Dec/12_03_2006/File1.txt")
    DEBUG [FTPConnection] 3 Dec 2006 11:38:56.934 : Invoking delegate EnterpriseDT.Net.Ftp.ExFTPConnection+a+a
    ALL [FTPConnection] 3 Dec 2006 11:38:56.934 : Have GUI control
    ALL [FTPConnection] 3 Dec 2006 11:38:56.934 : Invoking delegate dynamically
    DEBUG [FTPConnection] 3 Dec 2006 11:38:56.934 : Invoking delegate EnterpriseDT.Net.Ftp.FTPFileTransferEventHandler
    ALL [FTPConnection] 3 Dec 2006 11:38:56.934 : Have GUI control
    ALL [FTPConnection] 3 Dec 2006 11:38:56.934 : GUI control invocation required
    ALL [FTPConnection] 3 Dec 2006 11:38:56.934 : Beginning delegate invocation
    ALL [FTPConnection] 3 Dec 2006 11:38:56.950 : Delegate invocation begun - waiting for completion
    


    So, it looks like it is hanging for the Delegate execution to complete.

    Any ideas why this is happening ?


Thanks a lot in advance.

Indranil

1 Answer

0 votes
by (51.6k points)
Hi Indranil

[list=1]

[*] No, there is currently no way to do this in edtFTPnet/PRO. The best I can suggest is that you write your own method to do it.

[*] This is a threading problem which is usually caused by mixing synchronous methods with asynchronous methods. If possible please try to use either one or the other, but not both. If you cannot, or if this does not work, then please try setting ftpConnection.UseGuiThreadIfAvailable to false.

By default, when they're executing asynchronous methods, ExFTPConnection and SecureFTPConnection try to execute callbacks and event-handlers on the GUI thread. This has the advantage of avoiding the dreaded cross-thread exceptions. However, if the GUI thread is busy then you can end up having the callback/event-handler invocations hanging until the GUI thread becomes available. If the GUI thread is in effect waiting for the completion of the invocation then you'll get deadlocking.

Setting UseGuiThreadIfAvailable to false prevents this behavior. While this should stop the deadlocking, you are now likely to get cross-thread exceptions if you try to update your GUI from inside the callback/event-handler.

We have just completed some optimizations that should both speed up callback/event-handler invocations and also reduce the risk of deadlock, but these will not be released for some time.

- Hans (EDT)

Categories

...