473,387 Members | 1,791 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,387 software developers and data experts.

path too long problem

Before you respond with "just use GetShortPathName" please read the rest.

We have an application that places files on a file server using mapped
drives as it's path of choice. The reason for this is because using a UNC
paths makes the path longer, causing the periodic problem with a path that is
too long (over 260 chars).

We also have an asp.net app that needs to access those files. Accessing
mapped drives from an IIS application is not a viable option due to security
restrictions. UNC paths, however, are good except for the long path problem.

I've tried using the GetShortPathName win32 api but it apparently doesn't
accept arguments that exceed 260 characters. Not really helpful. Sometimes
I can get around this by stripping the filename, shortening the directory
path, and then appending the filename back onto the path. However, this
won't work if the directory path is over 260 characters.

So what I need is a way to shorten a path that is over 260 characters, which
is where GetShortPathName doesn't work.

Can anyone offer any suggestions?

Thanks,

Jeff
Jun 8 '07 #1
5 9996

"Jeff Beem" <Je******@discussions.microsoft.comwrote in message
news:A1**********************************@microsof t.com...
Before you respond with "just use GetShortPathName" please read the rest.

We have an application that places files on a file server using mapped
drives as it's path of choice. The reason for this is because using a UNC
paths makes the path longer, causing the periodic problem with a path that
is
too long (over 260 chars).

We also have an asp.net app that needs to access those files. Accessing
mapped drives from an IIS application is not a viable option due to
security
restrictions. UNC paths, however, are good except for the long path
problem.

I've tried using the GetShortPathName win32 api but it apparently doesn't
accept arguments that exceed 260 characters. Not really helpful.
Sometimes
I can get around this by stripping the filename, shortening the directory
path, and then appending the filename back onto the path. However, this
won't work if the directory path is over 260 characters.

So what I need is a way to shorten a path that is over 260 characters,
which
is where GetShortPathName doesn't work.

Can anyone offer any suggestions?
There is no solution for this, other than, to get the file path shorten on
the machine where the file is located. In other words, shorter file path
names on the machine.

Jun 9 '07 #2
Unfortunately shorter file path names is not a viable solution. This is an
Electronic Discovery application for litigation, which means all file names
and document metadata must remain intact.

I think I have a solution that will help. I'm taking the last directory
separator character prior to 260 and shortening the path up to that point and
then appending the rest back onto it. It is working so far but I haven't yet
tested in all of our scenarios.

Thanks for your input.
"Mr. Arnold" wrote:
>
"Jeff Beem" <Je******@discussions.microsoft.comwrote in message
news:A1**********************************@microsof t.com...
Before you respond with "just use GetShortPathName" please read the rest.

We have an application that places files on a file server using mapped
drives as it's path of choice. The reason for this is because using a UNC
paths makes the path longer, causing the periodic problem with a path that
is
too long (over 260 chars).

We also have an asp.net app that needs to access those files. Accessing
mapped drives from an IIS application is not a viable option due to
security
restrictions. UNC paths, however, are good except for the long path
problem.

I've tried using the GetShortPathName win32 api but it apparently doesn't
accept arguments that exceed 260 characters. Not really helpful.
Sometimes
I can get around this by stripping the filename, shortening the directory
path, and then appending the filename back onto the path. However, this
won't work if the directory path is over 260 characters.

So what I need is a way to shorten a path that is over 260 characters,
which
is where GetShortPathName doesn't work.

Can anyone offer any suggestions?

There is no solution for this, other than, to get the file path shorten on
the machine where the file is located. In other words, shorter file path
names on the machine.

Jun 9 '07 #3
Hello Jeff,

Use WinAPI and "\\?\" before the path, which switch to the UNICODE path and
allows manipulate with 32k path length

See there http://blogs.msdn.com/bclteam/archiv...-hamilton.aspx

---
WBR, Michael Nemtsev [.NET/C# MVP].
My blog: http://spaces.live.com/laflour
Team blog: http://devkids.blogspot.com/

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo

JBBefore you respond with "just use GetShortPathName" please read the
JBrest.
JB>
JBWe have an application that places files on a file server using
JBmapped drives as it's path of choice. The reason for this is
JBbecause using a UNC paths makes the path longer, causing the
JBperiodic problem with a path that is too long (over 260 chars).
JB>
JBWe also have an asp.net app that needs to access those files.
JBAccessing mapped drives from an IIS application is not a viable
JBoption due to security restrictions. UNC paths, however, are good
JBexcept for the long path problem.
JB>
JBI've tried using the GetShortPathName win32 api but it apparently
JBdoesn't accept arguments that exceed 260 characters. Not really
JBhelpful. Sometimes I can get around this by stripping the filename,
JBshortening the directory path, and then appending the filename back
JBonto the path. However, this won't work if the directory path is
JBover 260 characters.
JB>
JBSo what I need is a way to shorten a path that is over 260
JBcharacters, which is where GetShortPathName doesn't work.
JB>
JBCan anyone offer any suggestions?
JB>
JBThanks,
JB>
JBJeff
JB>
Jun 11 '07 #4
Thanks Michael. I found this solution a few days back also and we have
implemented it with great success. Hopefully Microsoft will someday release
a managed api for these methods, as there seems to be a real need for it.
Thanks again,

Jeff

"Michael Nemtsev" wrote:
Hello Jeff,

Use WinAPI and "\\?\" before the path, which switch to the UNICODE path and
allows manipulate with 32k path length

See there http://blogs.msdn.com/bclteam/archiv...-hamilton.aspx

---
WBR, Michael Nemtsev [.NET/C# MVP].
My blog: http://spaces.live.com/laflour
Team blog: http://devkids.blogspot.com/

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo

JBBefore you respond with "just use GetShortPathName" please read the
JBrest.
JB>
JBWe have an application that places files on a file server using
JBmapped drives as it's path of choice. The reason for this is
JBbecause using a UNC paths makes the path longer, causing the
JBperiodic problem with a path that is too long (over 260 chars).
JB>
JBWe also have an asp.net app that needs to access those files.
JBAccessing mapped drives from an IIS application is not a viable
JBoption due to security restrictions. UNC paths, however, are good
JBexcept for the long path problem.
JB>
JBI've tried using the GetShortPathName win32 api but it apparently
JBdoesn't accept arguments that exceed 260 characters. Not really
JBhelpful. Sometimes I can get around this by stripping the filename,
JBshortening the directory path, and then appending the filename back
JBonto the path. However, this won't work if the directory path is
JBover 260 characters.
JB>
JBSo what I need is a way to shorten a path that is over 260
JBcharacters, which is where GetShortPathName doesn't work.
JB>
JBCan anyone offer any suggestions?
JB>
JBThanks,
JB>
JBJeff
JB>
Jun 11 '07 #5
Hello Jeff,

They said that VS Orcas simplify this stuff, because the current solution
is not obvious for the beginners

---
WBR, Michael Nemtsev [.NET/C# MVP].
My blog: http://spaces.live.com/laflour
Team blog: http://devkids.blogspot.com/

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo

JBThanks Michael. I found this solution a few days back also and we
JBhave implemented it with great success. Hopefully Microsoft will
JBsomeday release a managed api for these methods, as there seems to
JBbe a real need for it. Thanks again,
JB>
JBJeff
JB>
JB"Michael Nemtsev" wrote:
JB>
>Hello Jeff,

Use WinAPI and "\\?\" before the path, which switch to the UNICODE
path and allows manipulate with 32k path length

See there
http://blogs.msdn.com/bclteam/archiv...aths-in-net-pa
rt-2-of-3-long-path-workarounds-kim-hamilton.aspx

---
WBR, Michael Nemtsev [.NET/C# MVP].
My blog: http://spaces.live.com/laflour
Team blog: http://devkids.blogspot.com/
"The greatest danger for most of us is not that our aim is too high
and we miss it, but that it is too low and we reach it" (c)
Michelangelo

JBBefore you respond with "just use GetShortPathName" please read
the
JBrest.
JB>
JBWe have an application that places files on a file server using
JBmapped drives as it's path of choice. The reason for this is
JBbecause using a UNC paths makes the path longer, causing the
JBperiodic problem with a path that is too long (over 260 chars).
JB>
JBWe also have an asp.net app that needs to access those files.
JBAccessing mapped drives from an IIS application is not a viable
JBoption due to security restrictions. UNC paths, however, are
good
JBexcept for the long path problem.
JB>
JBI've tried using the GetShortPathName win32 api but it apparently
JBdoesn't accept arguments that exceed 260 characters. Not really
JBhelpful. Sometimes I can get around this by stripping the
filename,
JBshortening the directory path, and then appending the filename
back
JBonto the path. However, this won't work if the directory path is
JBover 260 characters.
JB>
JBSo what I need is a way to shorten a path that is over 260
JBcharacters, which is where GetShortPathName doesn't work.
JB>
JBCan anyone offer any suggestions?
JB>
JBThanks,
JB>
JBJeff
JB>

Jun 11 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Bob | last post by:
Hi ! I got a problem here ... i used a ShellLinkObject is retrive some data from ..lnk files (path to execute, working directory, etc ...) but i need to get the icon path (in some case this is the...
4
by: Matt Sawyer | last post by:
I am attempting to use an API (CxApiOem.dll) that has a large number of defines and complicated structs. It's just too much hassle to attempt to use DLLImport to make the desired API calls. ...
6
by: I am Sam | last post by:
I keep getting this error and I don't know why: The path is too long after being fully qualified. Make sure path is less than 260 characters. Description: An unhandled exception occurred...
2
by: Seth | last post by:
Ok, here is my setup. I have a fully functioning HTTP Handler implemented. The handler is supposed to handle every single request that comes in to a particular virtual directory. Thus, in IIS, I...
3
by: Zenu | last post by:
Hi, I have a system with very long paths and I'm trying to use file.exist(Longpath) to test the paths existance but it gives a message that the path is too long. Can someone tell me how to...
5
by: Martin Carpella | last post by:
Hi! I know, that Path-names should be shorter than MAX_PATH (250), but the Win32-SDK allows specifiying longer names using the "\\?\" prefix. As I have an application that accesses files...
9
by: frankstuartbrowne | last post by:
This is a continuation the following post: http://www.thescripts.com/forum/thread659736.html The code I'm looking at is here, in the Finding Files and Directories part: ...
4
by: Vlad | last post by:
I am having problems using the file.create method within a function that is called when looping through an array of filepaths. If I call my function with a hardcoded file path --C:\Temp.txt the...
8
by: yguan08 | last post by:
I have trouble of obtaining the file size of a file because the fullpath exceeds 255 characters. I get this message with os.path.getsize(fullpath). fullpath = r"\\LOSSSFS002\NWE_TECHNICAL\05....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...

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.