Hi,
(Great component, thanks for the Freebie!)
I get a NullReferenceException when the file does not exist. Having quickly looked through the source and even attached the src project and debugged,
an FTPException is obviously what I should be getting and is what is thrown when I step through the edtFTP src. But via the Finally it looks like something is broken.
Sample code and stack trace below.
Output:
A first chance exception of type 'EnterpriseDT.Net.Ftp.FTPException' occurred in edtFTPnet.DLL
A first chance exception of type 'EnterpriseDT.Net.Ftp.FTPException' occurred in edtFTPnet.DLL
A first chance exception of type 'EnterpriseDT.Net.Ftp.FTPException' occurred in edtFTPnet.DLL
A first chance exception of type 'System.NullReferenceException' occurred in edtFTPnet.DLL
public byte[] GetFileData(PathInfo pathInfo)
{
byte[] data = null;
using (FTPConnection conn = GetConnection(pathInfo))
{
try
{
conn.ChangeWorkingDirectory(pathInfo.Directory);
data = conn.DownloadByteArray(pathInfo.Filename);
return data;
}
catch (FTPException ex)
{
}
return data;
}
}
System.NullReferenceException was unhandled
Message=Object reference not set to an instance of an object.
Source=edtFTPnet
StackTrace:
at EnterpriseDT.Net.Ftp.FTPConnection.OnDownloaded(Byte[] bytes, String remoteFile, Int64 bytesTransferred, Exception ex, Int64 remoteFileSize, DateTime remoteModTime)
at EnterpriseDT.Net.Ftp.FTPConnection.DownloadByteArray(String remoteFile)
at A.ClientLibrary.FileManagement.FTPFileManager.GetFileData(PathInfo pathInfo) in C:\Development\Projects\FileManager.cs:line 269
at A.ClientLibrary.FileManagement.FileManager.GetFileData(String path) in C:\Development\Projects\FileManager.cs:line 39
at A.Program.Main(String[] args) in C:\Development\Test\MockGenClientLibraryTest\Program.cs:line 20
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException: