Click here to Skip to main content
15,886,919 members
Articles / Desktop Programming / Win32

Another Flexible ListView Control

Rate me:
Please Sign up or sign in to vote.
4.59/5 (12 votes)
17 Jul 2010CPOL5 min read 37.7K   2.3K   47  
A highly object-oriented ListView control with varying-height items and support of complex data types
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace Guide
{
	public class IO
	{
		public const int TempFileNameLength = 4;

		private static Random random = new Random();

		public static string CreateTempFile(string path, string ext)
		{
			string filePath;

			do
			{
				string fileName = CreateTempFileName(ext);
				filePath = Path.Combine(path, fileName);
			}
			while (File.Exists(filePath));

			return filePath;
		}

		public static string CreateTempFileName(string ext)
		{
			return RandomFileName(TempFileNameLength) + ext;
		}

		private static string RandomFileName(int nChars)
		{
			StringBuilder s = new StringBuilder();

			for (int i = 0; i < nChars; i++)
			{
				int k = random.Next(10 + 'Z' - 'A' + 1);

				if (0 <= k && k <= 9)
					s.Append((char)(k + '0'));
				else if (k <= 10 + 'Z' - 'A')
					s.Append((char)('A' + k - 10));
				else
					throw new Exception("Shouldn't be here");
			}

			return s.ToString();
		}

		public void RunProcess(string path, string arguments)
		{

		}
	}
}

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
Software Developer (Senior)
Australia Australia
Master of IT, University of Technology Sydney

Bachelor Degree in Telecommunication, Hochiminh University of Technology, Vietnam

A few years of experience with .NET technology, computer graphics + animation, web development, algorithm design and many other things.

Comments and Discussions