Full path with double backslash (C#)

前端 未结 4 1777
感动是毒
感动是毒 2020-12-10 05:39

Is it possible to get a full path with double backslash by using Path.GetFullPath? Something like this:

C:\\\\Users\\\\Mammamia\\\\Videos\\\\Doc         


        
相关标签:
4条回答
  • 2020-12-10 06:20

    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("\\", "\\\\");
    
    0 讨论(0)
  • 2020-12-10 06:20

    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")
    
    0 讨论(0)
  • 2020-12-10 06:21

    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

    0 讨论(0)
  • 2020-12-10 06:32

    Do you mean this?

    Path.GetFullPath(path).Replace(@"\", @"\\");
    
    0 讨论(0)
提交回复
热议问题