> Hey state your problem with more clarity...so that we can help you!
>
[quoted text clipped - 17 lines]
>
> - Show quoted text -
This piece of code is to explain my problem. The code will create this
folder structure in the folder "Test"
Digibox
_Documentation
_Test
D
but i want it to be
D
_Test
_Documentation
Digibox
folderstructure based on FileInfo.FullName
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button2_Click(object sender, EventArgs e)
{
CopyDirectory(@"D:\_Test\_Documentatie\DigiBox
\Werkverslag.doc", @"D:\Test");
}
/// <summary>
///
/// </summary>
/// <param name="_src"></param>
/// <param name="_dst"></param>
private void CopyDirectory(string _src, string _dst)
{
FileInfo _file = new FileInfo(_src);
DirectoryInfo _dir = new
DirectoryInfo(_file.Directory.FullName);
DirectoryInfo _dest = new DirectoryInfo(_dst);
GetDirStructure(_dir, _dest);
}
/// <summary>
///
/// </summary>
/// <param name="_dirstrc"></param>
/// <param name="_dest"></param>
private void GetDirStructure(DirectoryInfo _dirstrc,
DirectoryInfo _dest)
{
if (_dirstrc.Parent != null)
{
if (_dest.Exists)
if (_regex.IsMatch(_dirstrc.Parent.Name) == true)
{
_dest.CreateSubdirectory(_regex.Match(_dirstrc.Parent.Name).Result("$
{drive}"));
}
else
{
_dest =
_dest.CreateSubdirectory(_dirstrc.Parent.Name);
}
GetDirStructure(_dirstrc.Parent, _dest);
}
}
iCodeSharp@gmail.com - 31 Jul 2007 12:48 GMT
On 31 Jul, 13:07, iCodeSh...@gmail.com wrote:
> > Hey state your problem with more clarity...so that we can help you!
>
[quoted text clipped - 83 lines]
>
> - Show quoted text -
This seems to help my me...totally different approach but it works
string filename = @"D:\_Test\_Documentatie\DigiBox\";
string drive = _regex.Match(filename).Result("${drive}");
string folderstr =
filename.Substring(filename.IndexOf(@"\"), filename.Length - 2);
if(!Directory.Exists(@"D:\_Test\" + drive + "\\" +
folderstr))
Directory.CreateDirectory(@"D:\_Test\" + drive + "\\" +
folderstr);