.NETGURU
How do I: use CreateDirectoryEx to create a Directory 300+ characters? - Using Unicode Build
Messages   Related Types
This message was discovered on microsoft.public.dotnet.languages.vc.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
Post a new message to this list...

Russell Mangel
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;
}

Reply to this message...
 
    
Ronald Laeremans [MSFT] (VIP)
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

"Russell Mangel" <Click here to reveal e-mail address> wrote in message
news:uUWS%Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
 




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification