Click here to Skip to main content
15,894,343 members
Articles / Programming Languages / C#

Application for uploading modified Files to a FTP Server

Rate me:
Please Sign up or sign in to vote.
4.73/5 (16 votes)
14 Oct 2002CPOL2 min read 200.5K   4.4K   80  
Simple C# Console Application that uses a local MS-Access Database to store modification Dates of Files and uploads modified Files to a FTP Server
using System;
using System.Collections;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

namespace KCommon.Net.FTP
{
	//I decide not to use UCOMIEnumVariant since I got no idea how 
	//to Marshal int back to array. As a result, I re-define the
	//IEnumVARIANT interface to simplified my work
	[	
		Guid("00020404-0000-0000-C000-000000000046"),
		InterfaceType(ComInterfaceType.InterfaceIsIUnknown)
	]
	public interface IEnumVARIANT
	{
		[MethodImpl(MethodImplOptions.PreserveSig)]
		int Next(UInt32 celt, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex=0), Out]object[] rgelt, IntPtr pceltFetched);
		void Skip(UInt32 celt);
		void Reset();
		void Clone(int ppenum);
	}

	[Guid("A4C46780-499F-101B-BB78-00AA00383CBB")]
	public interface IVBCollection
	{
		[DispId(0)]
		object Item([In]ref object Index);

		[DispId(1)]
		void Add([In]ref object Item, [In, Optional]ref object Key, [In, Optional]ref object Before, [In, Optional]ref object After);

		[DispId(2)]
		Int32 Count();

		[DispId(3)]
		void Remove([In]ref object Index);

		[DispId(-4)]
		[return : MarshalAs(UnmanagedType.IUnknown)]
		object _NewEnum();
	}

	[
		Guid("A4C4671C-499F-101B-BB78-00AA00383CBB"),
		ClassInterface(ClassInterfaceType.None)
	]
	public class VbEnumableCollection : IVBCollection , IEnumVARIANT, IEnumerable
	{
		ICollection				m_collection;
		IEnumerator				m_enumerator;
		
		internal VbEnumableCollection(ICollection c)
		{
			m_collection = c;
			m_enumerator = c.GetEnumerator();
		}
		
		#region Implementation of IEnumerable
		public IEnumerator GetEnumerator()
		{
			return m_enumerator;
		}
		#endregion

		#region Implementation of IVBCollection
		public object Item(ref object Index)
		{
			throw new NotSupportedException("Method Item() not supported for VbEnumableCollection.");
		}
		public void Add(ref object Item, ref object Key, ref object Before, ref object After)
		{
			throw new NotSupportedException("Method Add() not supported for VbEnumableCollection.");
		}
		public Int32 Count()
		{
			return m_collection.Count;
		}
		public void Remove(ref object Index)
		{
			throw new NotSupportedException("Method Remove() not supported for VbEnumableCollection.");
		}
		public object _NewEnum()
		{
			return new VbEnumableCollection(m_collection);
		}
		#endregion

		#region Implementation of IEnumVariant
		public int Next(UInt32 celt, object[] rgelt, IntPtr pceltFetched)
		{
			if(pceltFetched != IntPtr.Zero)
				Marshal.WriteInt32(pceltFetched, 0);
			if(celt > 1)
				throw new NotSupportedException("Each time can fetch one item in VbCallableCollection.");
			if(m_enumerator.MoveNext()) {
				rgelt[0] = m_enumerator.Current;
				if(pceltFetched != IntPtr.Zero)
					Marshal.WriteInt32(pceltFetched, 1);
				return 0; //S_OK
			}else
				return 1; //S_FALSE
		}
		public void Skip(UInt32 celt)
		{
			throw new NotSupportedException("Method Skip() not supported in VbEnumerableCollection.");
		}
		public void Reset()
		{
			m_enumerator.Reset();
		}
		public void Clone(int ppenum)
		{
			throw new NotSupportedException("Cannot clone interface.");
		}
		#endregion
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Chief Technology Officer Zeta Software GmbH
Germany Germany
Uwe does programming since 1989 with experiences in Assembler, C++, MFC and lots of web- and database stuff and now uses ASP.NET and C# extensively, too. He has also teached programming to students at the local university.

➡️ Give me a tip 🙂

In his free time, he does climbing, running and mountain biking. In 2012 he became a father of a cute boy and in 2014 of an awesome girl.

Some cool, free software from us:

Windows 10 Ereignisanzeige  
German Developer Community  
Free Test Management Software - Intuitive, competitive, Test Plans.  
Homepage erstellen - Intuitive, very easy to use.  
Offline-Homepage-Baukasten

Comments and Discussions