Solved

Create Directory with DirectoryInfo class

Posted on 2003-11-11
4
588 Views
Last Modified: 2010-05-18
Hi,

   I am using the DirectoryInfo class to create directories. However there is a 260 character limitations to the length of
   the directory name which I maxing out on. Any way around this ?



Thanks


Robert
0
Comment
Question by:rogaut1
  • 3
4 Comments
 
LVL 22

Expert Comment

by:_TAD_
ID: 9726044


What kind of directory has a name that is more than 260 characters?!?
(hmm... and I thought windows set a limit at 254 chars... odd that .Net lets you add a few more.  I could be wrong though.)


At any rate, I am going to guess that you are NOT creating a directory name of 260+ characters, but are in fact trying to create a subdirectory several directories deep.

Assuming that is the case, you could get to 260 characters pretty fast.


If this is the case, you do not want to use DiretoryInfo class.  This class is geared for Instances of directories.


use this code:

Directory.CreateDirectory(strAReallyLongDirectoryStructure);
0
 
LVL 22

Expert Comment

by:_TAD_
ID: 9726082


Ack!


Ok... I tried out my own code and got the same error.

It looks like you'll have to do it recursively in order to get it done.
0
 
LVL 22

Accepted Solution

by:
_TAD_ earned 125 total points
ID: 9726158


Turns out it is a Windows limitation


Try doing it manually and you'll get all kinds of errors.

C:\temp\subFolderOrDirectoryWithReallyLongName\subFolderOrDirectoryWithReallyLongName\subFolderOrDirectoryWithReallyLongName\subFolderOrDirectoryWithReallyLongName\subFolderOrDirectoryWithReallyLongName


works just fine.


C:\temp\subFolderOrDirectoryWithReallyLongName\subFolderOrDirectoryWithReallyLongName\subFolderOrDirectoryWithReallyLongName\subFolderOrDirectoryWithReallyLongName\subFolderOrDirectoryWithReallyLongName\subFolderOrDirectoryWithReallyLongName


Throws an error in windows and it was really easy to test manually.

0
 
LVL 2

Author Comment

by:rogaut1
ID: 9726200
Thanks for your help !

I will have to convert the names I guess....


Robert
0

Featured Post

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that undeā€¦
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question