472,988 Members | 2,740 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,988 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 9959

"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: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...
3
SueHopson
by: SueHopson | last post by:
Hi All, I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...

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.