path too long problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
Jeff Beem said:
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.
 
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.
 
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/archi...-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

JB> Before you respond with "just use GetShortPathName" please read the
JB> rest.
JB>
JB> We have an application that places files on a file server using
JB> mapped drives as it's path of choice. The reason for this is
JB> because using a UNC paths makes the path longer, causing the
JB> periodic problem with a path that is too long (over 260 chars).
JB>
JB> We also have an asp.net app that needs to access those files.
JB> Accessing mapped drives from an IIS application is not a viable
JB> option due to security restrictions. UNC paths, however, are good
JB> except for the long path problem.
JB>
JB> I've tried using the GetShortPathName win32 api but it apparently
JB> doesn't accept arguments that exceed 260 characters. Not really
JB> helpful. Sometimes I can get around this by stripping the filename,
JB> shortening the directory path, and then appending the filename back
JB> onto the path. However, this won't work if the directory path is
JB> over 260 characters.
JB>
JB> So what I need is a way to shorten a path that is over 260
JB> characters, which is where GetShortPathName doesn't work.
JB>
JB> Can anyone offer any suggestions?
JB>
JB> Thanks,
JB>
JB> Jeff
JB>
 
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
 
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

JB> Thanks Michael. I found this solution a few days back also and we
JB> have implemented it with great success. Hopefully Microsoft will
JB> someday release a managed api for these methods, as there seems to
JB> be a real need for it. Thanks again,
JB>
JB> Jeff
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/archive/2007/03/26/long-paths-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

JB> Before you respond with "just use GetShortPathName" please read
the
JB> rest.
JB>
JB> We have an application that places files on a file server using
JB> mapped drives as it's path of choice. The reason for this is
JB> because using a UNC paths makes the path longer, causing the
JB> periodic problem with a path that is too long (over 260 chars).
JB>
JB> We also have an asp.net app that needs to access those files.
JB> Accessing mapped drives from an IIS application is not a viable
JB> option due to security restrictions. UNC paths, however, are
good
JB> except for the long path problem.
JB>
JB> I've tried using the GetShortPathName win32 api but it apparently
JB> doesn't accept arguments that exceed 260 characters. Not really
JB> helpful. Sometimes I can get around this by stripping the
filename,
JB> shortening the directory path, and then appending the filename
back
JB> onto the path. However, this won't work if the directory path is
JB> over 260 characters.
JB>
JB> So what I need is a way to shorten a path that is over 260
JB> characters, which is where GetShortPathName doesn't work.
JB>
JB> Can anyone offer any suggestions?
JB>
JB> Thanks,
JB>
JB> Jeff
JB
 
All Problems have ONE solution and that is:

www.longPathTool.com


Path too long.

Error cannot delete file: cannot read from source file or disk

Cannot delete file: Access is denied

There has been a sharing violation.

Cannot delete file or folder The file name you specified
is not valid or too long. Specify a different file name.

The source or destination file may be in use.

The file is in use by another program or user.

Error Deleting File or Folder

Make sure the disk is not full or write-protected and that the file is not currently in use.

Path too deep.


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
On Saturday, June 09, 2007 3:47 AM Mr. Arnold wrote:
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.
On Wednesday, June 13, 2007 1:51 AM 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/archi...-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

JB> Before you respond with "just use GetShortPathName" please read the
JB> rest.
JB>
JB> We have an application that places files on a file server using
JB> mapped drives as it's path of choice. The reason for this is
JB> because using a UNC paths makes the path longer, causing the
JB> periodic problem with a path that is too long (over 260 chars).
JB>
JB> We also have an asp.net app that needs to access those files.
JB> Accessing mapped drives from an IIS application is not a viable
JB> option due to security restrictions. UNC paths, however, are good
JB> except for the long path problem.
JB>
JB> I've tried using the GetShortPathName win32 api but it apparently
JB> doesn't accept arguments that exceed 260 characters. Not really
JB> helpful. Sometimes I can get around this by stripping the filename,
JB> shortening the directory path, and then appending the filename back
JB> onto the path. However, this won't work if the directory path is
JB> over 260 characters.
JB>
JB> So what I need is a way to shorten a path that is over 260
JB> characters, which is where GetShortPathName doesn't work.
JB>
JB> Can anyone offer any suggestions?
JB>
JB> Thanks,
JB>
JB> Jeff
JB>
 
All Problems have ONE solution and that is:

www.longPathTool.com


Path too long.

Error cannot delete file: cannot read from source file or disk

Cannot delete file: Access is denied

There has been a sharing violation.

Cannot delete file or folder The file name you specified
is not valid or too long. Specify a different file name.

The source or destination file may be in use.

The file is in use by another program or user.

Error Deleting File or Folder

Make sure the disk is not full or write-protected and that the file is not currently in use.

Path too deep.


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
On Saturday, June 09, 2007 3:47 AM Mr. Arnold wrote:
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.
On Wednesday, June 13, 2007 1:51 AM 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/archi...-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

JB> Before you respond with "just use GetShortPathName" please read the
JB> rest.
JB>
JB> We have an application that places files on a file server using
JB> mapped drives as it's path of choice. The reason for this is
JB> because using a UNC paths makes the path longer, causing the
JB> periodic problem with a path that is too long (over 260 chars).
JB>
JB> We also have an asp.net app that needs to access those files.
JB> Accessing mapped drives from an IIS application is not a viable
JB> option due to security restrictions. UNC paths, however, are good
JB> except for the long path problem.
JB>
JB> I've tried using the GetShortPathName win32 api but it apparently
JB> doesn't accept arguments that exceed 260 characters. Not really
JB> helpful. Sometimes I can get around this by stripping the filename,
JB> shortening the directory path, and then appending the filename back
JB> onto the path. However, this won't work if the directory path is
JB> over 260 characters.
JB>
JB> So what I need is a way to shorten a path that is over 260
JB> characters, which is where GetShortPathName doesn't work.
JB>
JB> Can anyone offer any suggestions?
JB>
JB> Thanks,
JB>
JB> Jeff
JB>
 
All Problems have ONE solution and that is:

www.longPathTool.com


Path too long.

Error cannot delete file: cannot read from source file or disk

Cannot delete file: Access is denied

There has been a sharing violation.

Cannot delete file or folder The file name you specified
is not valid or too long. Specify a different file name.

The source or destination file may be in use.

The file is in use by another program or user.

Error Deleting File or Folder

Make sure the disk is not full or write-protected and that the file is not currently in use.

Path too deep.


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
On Saturday, June 09, 2007 3:47 AM Mr. Arnold wrote:
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.
On Wednesday, June 13, 2007 1:51 AM 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/archi...-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

JB> Before you respond with "just use GetShortPathName" please read the
JB> rest.
JB>
JB> We have an application that places files on a file server using
JB> mapped drives as it's path of choice. The reason for this is
JB> because using a UNC paths makes the path longer, causing the
JB> periodic problem with a path that is too long (over 260 chars).
JB>
JB> We also have an asp.net app that needs to access those files.
JB> Accessing mapped drives from an IIS application is not a viable
JB> option due to security restrictions. UNC paths, however, are good
JB> except for the long path problem.
JB>
JB> I've tried using the GetShortPathName win32 api but it apparently
JB> doesn't accept arguments that exceed 260 characters. Not really
JB> helpful. Sometimes I can get around this by stripping the filename,
JB> shortening the directory path, and then appending the filename back
JB> onto the path. However, this won't work if the directory path is
JB> over 260 characters.
JB>
JB> So what I need is a way to shorten a path that is over 260
JB> characters, which is where GetShortPathName doesn't work.
JB>
JB> Can anyone offer any suggestions?
JB>
JB> Thanks,
JB>
JB> Jeff
JB>
 
Back
Top