Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / September 2004

Tip: Looking for answers? Try searching our database.

How do I: use CreateDirectoryEx to create a Directory 300+ characters? - Using Unicode Build

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Russell Mangel - 08 Sep 2004 13:42 GMT
Hi, I am trying to create a directory on my disk wihich is 300+ characters
long.
My program does not work, can you make it go? I am using VS2003 C++.

Russell Mangel, Las Vegas, NV

// I have specified Unicode Character set in project settings
#include "stdafx.h"
#include <windows.h>
int _tmain(int argc, _TCHAR* argv[])
{
// Assumes that you have an existing directory: C:\\A
LPCTSTR lpTemplateDirectory= _T("C:\\A");

// This is a 300+ Character Directory, ANSI is limited to 248 chars
// I think I have the \\?\ in the right place?
LPCTSTR lpNewDirectory =
_T("\\?\C:\\A\\0000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000-000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000-00000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000");

if(CreateDirectoryEx(lpTemplateDirectory, lpNewDirectory, NULL))
{
 printf("Successfully created: %s", lpNewDirectory);
}
else
{
 printf("Error: %d", GetLastError());
}
return 0;
}
Ronald Laeremans [MSFT] - 09 Sep 2004 09:00 GMT
Hi Russel,

I think you are misunderstanding 1 critical piece: each component of the
path can still only be 255 characters.

This is from the MDSN doc topic:
"The Unicode versions of several functions permit a maximum path length of
32,767 characters, composed of components up to 255 characters in length."

In addition, you are forgetting to escape the first double-\.

You would need:

\\\\?\\C:\\A\\.

Ronald Laeremans
Visual C++ team

> Hi, I am trying to create a directory on my disk wihich is 300+ characters
> long.
[quoted text clipped - 29 lines]
> return 0;
> }

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.