Solved

Create Directory with DirectoryInfo class

Posted on 2003-11-11
4
586 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
c# if statement weird reaction 3 42
Definitions and default visual studio colors 5 58
Run time Error 4 34
C# Comparing String Arrays. 5 0
Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…
Both in life and business – not all partnerships are created equal. Spend 30 short minutes with us to learn:   • Key questions to ask when considering a partnership to accelerate your business into the cloud • Pitfalls and mistakes other partners…

911 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

19 Experts available now in Live!

Get 1:1 Help Now