Solved

Create Directory with DirectoryInfo class

Posted on 2003-11-11
4
585 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_
Comment Utility


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_
Comment Utility


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
Comment Utility


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
Comment Utility
Thanks for your help !

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


Robert
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

743 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now