Visual Studio-PathTooLongException即使路径长度小于260个字符 [英] Visual Studio - PathTooLongException even when the path length is less than 260 characters

查看:121
本文介绍了Visual Studio-PathTooLongException即使路径长度小于260个字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道创建项目时允许的最大路径长度为260个字符,目录的最大字符为248个字符. 但是,即使我的路径长度少于200个字符,我也会收到此错误.

I know that max path length allowed while creating a project is 260 characters and 248 characters for directory. But I'm getting this error even when my my path length is less than 200 characters.

我的解决方案文件位于此文件夹C:\ Users \ username \ Documents \ Visual Studio 2010 \ Projects \ Health12.Domain12.WardManagement => 88个字符 当我尝试向该解决方案添加名称为"Health12.Domain12.WardManagement.Service.Contract"的新类库时,它给了我路径太长的异常.

My solution file resides in this folder C:\Users\username\Documents\Visual Studio 2010\Projects\Health12.Domain12.WardManagement => 88 characters When I try to add a new class library with name "Health12.Domain12.WardManagement.Service.Contract" to this solution, it gives me path too long exception.

C:\ Users \ username \ Documents \ Visual Studio 2010 \ Projects \ Health12.Domain12.WardManagement \ Health12.Domain12.WardManagement.Service.Contract => 138个字符

C:\Users\username\Documents\Visual Studio 2010\Projects\Health12.Domain12.WardManagement\Health12.Domain12.WardManagement.Service.Contract => 138 characters

C:\ Users \ username \ Documents \ Visual Studio 2010 \ Projects \ Health12.Domain12.WardManagement \ Health12.Domain12.WardManagement.Service.Contract \ Health12.Domain12.WardManagement.Service.Contract.csproj => 195个字符

C:\Users\username\Documents\Visual Studio 2010\Projects\Health12.Domain12.WardManagement\Health12.Domain12.WardManagement.Service.Contract\Health12.Domain12.WardManagement.Service.Contract.csproj => 195 characters

所有可能的文件或文件夹都没有超过260个字符的限制.

None of the possible files or folders crosses the 260 character limit.

如果我将项目名称从"Health12.Domain12.WardManagement.Service.合同"更改为"Health12.Domain12.WardManagement.Service. Con ",那么它将起作用美好的. 知道为什么Visual Studio即使不超过允许的最大长度限制也不允许创建项目.

If i change the project name from "Health12.Domain12.WardManagement.Service.Contract" to "Health12.Domain12.WardManagement.Service.Con", it works fine. Any idea why visual studio won't allow to create project even when it is not crossing max allowed length limit.

推荐答案

Visual Studio中路径的长度计算如下:

The length of the path in Visual Studio is computed as follow:

  1. 解决方案的路径:C:\Users\username\Documents\Visual Studio 2010\Projects\Health12.Domain12.WardManagement\ = 89个字符
  2. 2 *项目名称:Health12.Domain12.WardManagement.Service.Contract\ = 50个字符
  3. 保留字符:项目中文件,编译文件,临时文件的附加字符,... = 80个字符
  1. Path to solution: C:\Users\username\Documents\Visual Studio 2010\Projects\Health12.Domain12.WardManagement\ = 89 chars
  2. 2 * Project name : Health12.Domain12.WardManagement.Service.Contract\ = 50 chars
  3. Reserved chars : Additionnal characters for the files in the project, the compiled files, temporary files, ... = 80 chars

在您的情况下:89 + 2 * 50 + 80 = 269

In your case: 89 + 2*50 + 80 = 269

限制为259((Drive char):\(256-character path))(请参见命名文件,路径和命名空间)

The limit is 259 ((Drive char):\(256-character path)) (see Naming Files, Paths, and Namespaces)

您必须删除10个字符.您可以将项目路径的长度减少10个字符,或者在项目名称中删除5个字符(例如"tract"的作品).

You have to remove 10 chars. Either you reduce the length of the path to the project by 10 chars or you remove 5 chars in the project name ("tract" for example works).

这篇关于Visual Studio-PathTooLongException即使路径长度小于260个字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆