473,405 Members | 2,154 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Long to Short pathnames without p/invoke

balabaster
797 Expert 512MB
Does anyone know how to get a file's short pathname in 3.5? (Without p/invoke)

I've got a file compare routine that runs a diff on two directories returning the differences of every file (attributes, times, permissions, crc etc) in the tree below the two roots.

Now, if the file structure is too deep, my app can't get at the files. Obviously I can't just take the first 6 chars and append ~1 because of potential duplication of short folder/file names.

I've found numerous old ways of doing this using p/invoke - but I detest using p/invoke unless there's absolutely no other choice.
Dec 4 '08 #1
4 1459
Curtis Rutland
3,256 Expert 2GB
Win32 API is the only way I've seen to do this, myself.
Dec 4 '08 #2
balabaster
797 Expert 512MB
@insertAlias
Grrr, I was hoping not to hear that...
Dec 4 '08 #3
Plater
7,872 Expert 4TB
How deep can the file structure go before the .NET calls stop working?
I don't think I have ever run into this?
Dec 4 '08 #4
balabaster
797 Expert 512MB
@Plater
According to this document:

http://msdn.microsoft.com/en-us/libr...fo(VS.71).aspx

No more than 248 chars for the path length and no more than 260 chars for the file name length.

Now, doesn't the path include the file name? If so, wouldn't a file that's got a name containing 260 chars automatically fail the 248 char length of the path? After all, even if it's in the root directory on a drive that's 3 extra chars pushing the path to 263?

I assume it must mean that the path name is only considered as the path to the directory that contains the file. It seems to me that decision was short sighted. There's far more potential to have a longer path name than 248 chars than there is having a file name with anywhere close to 260 chars. If someone handed me a file that was named something that long, the first thing I'd do would be rename it!

It just screams "I didn't know what to call this file, so I sat and thought about it for a while and came up with nothing, so I'm just going to name it this.txt"
Dec 4 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Lars Behrens | last post by:
Hi, Pythonistas! I'm quite new to Python and have a problem with a simple backup script. This code: tar = tarfile.open('/home/lars/test.tar.gz', 'w:gz') tar.addfile('/home/lars') brings...
99
by: Glen Herrmannsfeldt | last post by:
I was compiling a program written by someone else about six years ago, and widely distributed at the time. It also includes makefiles for many different systems, so I know it has been compiled...
11
by: Ken Durden | last post by:
I am in search of a comprehensive methodology of using these two object cleanup approaches to get rid of a number of bugs, unpleasantries, and cleanup-ordering issues we currently have in our...
6
by: Charles Conlow | last post by:
I'm certain there's a simple way to do this, but I just can't find the pointers... How to get the huge 'drive:\long\path\to get\there\filename.ext' to something like 'D:\Docu...\filename.ext' ...
3
by: Robert W. | last post by:
In my WinForms app I'm retrieving the command line arguments with this standard code: static void Main(string args) Here's the problem. I've now associated my app with a particular...
22
by: Sven-Thorsten Fahrbach | last post by:
Hi Does anybody know of a library that offers a function to split pathnames. It should work somewhat like the following code snippet: ----------------- char *path =...
73
by: Yevgen Muntyan | last post by:
Hey, I was reading C99 Rationale, and it has the following two QUIET CHANGE paragraphs: 6.5.3.4: "With the introduction of the long long and extended integer types, the sizeof operator may...
8
by: Phil Endecott | last post by:
Dear Experts, I'm surprised to find that std::max doesn't work (i.e. won't compile) if the arguments are not of exactly the same type, e.g. one is a short and the other is a long: #include...
21
by: Bart C | last post by:
I've always had a problem knowing exactly how wide my integer variables were in C, and the little program below has increased my confusion. Run on 3 compilers on the same cpu (32-bit pentium),...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.