473,657 Members | 2,434 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

path too long problem

Before you respond with "just use GetShortPathNam e" 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 GetShortPathNam e 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 GetShortPathNam e doesn't work.

Can anyone offer any suggestions?

Thanks,

Jeff
Jun 8 '07 #1
5 10028

"Jeff Beem" <Je******@discu ssions.microsof t.comwrote in message
news:A1******** *************** ***********@mic rosoft.com...
Before you respond with "just use GetShortPathNam e" 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 GetShortPathNam e 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 GetShortPathNam e 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******@discu ssions.microsof t.comwrote in message
news:A1******** *************** ***********@mic rosoft.com...
Before you respond with "just use GetShortPathNam e" 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 GetShortPathNam e 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 GetShortPathNam e 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 GetShortPathNam e" 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 GetShortPathNam e 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 GetShortPathNam e 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 GetShortPathNam e" 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 GetShortPathNam e 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 GetShortPathNam e 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 GetShortPathNam e" 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 GetShortPathNam e 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 GetShortPathNam e 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
5572
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 same as the exe, but this is not always this !). I found the function GetIconPath, but this is returning only the "icon index" in the file (exe, dll), I need the path too, specially if the icon path is an .ico file. Here is a sample of my...
4
6890
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. Instead, I created a managed C++ DLL (OneBoxAPI.dll) that wraps the desired API calls in a manner which is easy to call from C#. This way I can use the header files that are part of the API for all the defines and structs. I am having a problem...
6
2576
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 during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.IO.PathTooLongException: The path is too long
2
3869
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 have a mapping of .* to the aspnet_isapi.dll. And my web.config has an entry thusly: <add verb="*" path="*" type="HandlerClass, HandlerAssembly" /> And this is working just fine thus far. The handler gets all the requests and works like a...
3
3193
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 manupulate long path in VB.NET. I am refering to fully qualified paths over 32000 characters where each component of the path could be up to 255 characters.
5
10309
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 directly using the volume name instead of the drive letter (i.e. "\\?\Volume{...}\subdir\file.ext"), I sometimes get an PathTooLongException, as the total string exceeds 260 characters (due to the "\\?\Volume{...}\"-part).
9
3816
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: http://blogs.msdn.com/bclteam/archive/2007/03/26/long-paths-in-net-part-2-of-3-long-path-workarounds-kim-hamilton.aspx I've gotten the code to run, but it crashes on the following line:
4
6901
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 function creates the file as expected. When I loop through my array I get the error - "ArgumentException was unhandled - Illegal characters in path" The value "C:\Temp.txt" is the first value in the array - as it works
8
9111
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. UK\Schiehallion (204_25a) \Amos&Burke_P559\07. Technical (Subsurface)\06. Well Planning\Amos \Daily Reports\Wireline\final_204_25a_8z\204_25a_8z\Run_1A \HRLA_SP_DSI_PEX_HNGS_ECRD\ANCILLARY\Amos_204_25a-8Z_GR_to_surface_3-...
0
8395
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8826
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8732
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
6166
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4155
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4306
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1955
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1615
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.