Full path with double backslash (C#)

为君一笑 提交于 2019-11-28 10:08:19

Do you mean this?

Path.GetFullPath(path).Replace(@"\", @"\\");

C:\\Users\\Mammamia\\Videos\\Documents\\CFD\\geo_msh\\cubeOp.txt is not a valid path, so I'm not sure why you'd want it, but:

Path.GetFullPath(yourPath).Replace("\\", "\\\\");

You can just do this:

Path.GetFullPath(@"C:\\Users\\Mammamia\\Videos\\Documents\\CFD\\geo_msh\\cubeOp.txt")

But i'm not sure why, you want to escape the \ ?

If yes, you can do just this :

 Path.GetFullPath(@"C:\Users\Mammamia\Videos\Documents\CFD\geo_msh\cubeOp.txt")

I would recommend doing a String.replace(). I recently had to do this in a project for myself. So if you do something similar to:

String input = Path.GetFullPath(x);
input = input.Replace("\\","\\\\");

I am fairly confident that is what you need :)

Documentation: http://msdn.microsoft.com/en-us/library/fk49wtc1.aspx

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!