hey, here i have a question. i want to select a directory path alone... For example, by using "openfiledialog" control, we can select the file path (eg., d:\sample\dest.txt). But i want to select only the path (eg., d:\sample\).... can anyone help me ? thanks in advance...........

or role your own if you don't want to import IO library for such trivial things;

public class MyPathInfo
	{
		public MyPathInfo()
		{
			//
			// TODO: Add constructor logic here
			//
		}

		public static string GetDir(string path)
		{
			string dir = path.Substring(0, findLastSlash(path)+1);

			return dir;
		}

		private static int findLastSlash(string path)
		{
			int curPos = 0;
			int slashPos = -1;
			int startPos = 0;

			while(curPos != -1)
			{
				if(startPos > 0)
					slashPos = curPos;

				curPos = path.IndexOf("/", startPos);
				startPos = curPos;
				startPos++;
			}

			return slashPos;
		}
	}

Sorry it's C# but I can't type VB anymore I did it for years, but now it just makes my teeth jangle ;)

thanks for all ur replies.........i found the answer...using 'browseforfolder' control and "selectedpath" function we can get it

This article has been dead for over six months. Start a new discussion instead.