如何更改此路径C:\ Windows \ SHELLNEW \ EXCEL12.XLSX到此路径C:\\Windows \\SHELLNEW \\EXCEL12.XLSX [英] how to change this path C:\Windows\SHELLNEW\EXCEL12.XLSX to this path C:\\Windows\\SHELLNEW\\EXCEL12.XLSX

查看:1270
本文介绍了如何更改此路径C:\ Windows \ SHELLNEW \ EXCEL12.XLSX到此路径C:\\Windows \\SHELLNEW \\EXCEL12.XLSX的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何更改此路径C:\ Windows \ SHELLNEW \ EXCEL12.XLSX到此路径C:\\Windows \\SHELLNEW \\EXCEL12.XLSX

解决方案

你可以这样做



string newpath = @C:\ Windows \ SHELLNEW \ EXCEL12.XLSX ;


如果您计划在运行时使用该路径,则不需要路径名中的额外'\''。



如果您输入代码,那么只需添加''\'',因为它是c#的转义码。或者您可以使用''@''字符:

  string  path =  @  C:\ Windows \ SHELLNEW \ EXCEL12.XLSX; 


如果你想在运行时改变那么试试这个

  string  path =   C:\ Windows \ SHELLNEW \ EXCEL12.XLSX; 
path = path.Replace( \, \\ );


how to change this path C:\Windows\SHELLNEW\EXCEL12.XLSX to this path C:\\Windows\\SHELLNEW\\EXCEL12.XLSX

解决方案

U can do like this

string newpath =@"C:\Windows\SHELLNEW\EXCEL12.XLSX";


If you plan to use the path at runtime you don''t need the extra ''\'' in the path names.

If you are typing in code then just add the ''\'' yourself since it is an escape code for c#. or you can use the ''@'' character :

string path = @"C:\Windows\SHELLNEW\EXCEL12.XLSX";


if you want to change at run time then try this

string path="C:\Windows\SHELLNEW\EXCEL12.XLSX";
path=path.Replace("\", "\\");


这篇关于如何更改此路径C:\ Windows \ SHELLNEW \ EXCEL12.XLSX到此路径C:\\Windows \\SHELLNEW \\EXCEL12.XLSX的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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