469,365 Members | 1,785 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,365 developers. It's quick & easy.

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 9580

"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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Matt Sawyer | last post: by
6 posts views Thread by I am Sam | last post: by
3 posts views Thread by Zenu | last post: by
5 posts views Thread by Martin Carpella | last post: by
8 posts views Thread by yguan08 | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.