?
Solved

Create Directory with DirectoryInfo class

Posted on 2003-11-11
4
Medium Priority
?
607 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 500 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

807 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