C# 如何在c中使用相对路径查找绝对路径#
我有一个存储在变量中的路径,比如说C# 如何在c中使用相对路径查找绝对路径#,c#,absolute-path,C#,Absolute Path,我有一个存储在变量中的路径,比如说 string partialPath = '\editors\tinymce' 我想得到上面五个的整个路径。上述文件的实际路径为“D:\backup\editors\tinymce”。我怎样才能在C#中做到这一点。谢谢这可能会帮到你 string partialPath = "\editors\tinymce"; string fullPath = Path.GetFullPath(partialPath); string partialPath = "
string partialPath = '\editors\tinymce'
我想得到上面五个的整个路径。上述文件的实际路径为“D:\backup\editors\tinymce”。我怎样才能在C#中做到这一点。谢谢这可能会帮到你
string partialPath = "\editors\tinymce";
string fullPath = Path.GetFullPath(partialPath);
string partialPath = "editors\tinymce";
fullPath = Path.GetFullPath(partialPath);
输出:
D:\editors\t编辑
鉴于
这可能对你有用
string partialPath = "\editors\tinymce";
string fullPath = Path.GetFullPath(partialPath);
string partialPath = "editors\tinymce";
fullPath = Path.GetFullPath(partialPath);
输出:
D:\backup\editors\t备份
这可能对你有用
string partialPath = "\editors\tinymce";
string fullPath = Path.GetFullPath(partialPath);
string partialPath = "editors\tinymce";
fullPath = Path.GetFullPath(partialPath);
输出:
D:\editors\t编辑
鉴于
这可能对你有用
string partialPath = "\editors\tinymce";
string fullPath = Path.GetFullPath(partialPath);
string partialPath = "editors\tinymce";
fullPath = Path.GetFullPath(partialPath);
输出:
D:\backup\editors\t备份
请使用以下代码进行尝试: 代码: 您可以获取输出变量和str字符串的路径
请告诉我们。请使用以下代码进行尝试: 代码: 您可以获取输出变量和str字符串的路径
请让我们知道。警告:不要在路径前加“\”,否则您将得到D:\editors\t相对路径相对于当前文件夹或特定文件夹。如果当前文件夹位于C:,则路径指向
C:\editors\tinymce
。如果希望此路径指向另一个驱动器,则必须指定它。为什么要用D:
而不是例如E:`或Z:`?警告:不要在路径前加“\”,否则您将得到D:\editors\t相对路径是相对于当前文件夹或特定文件夹的。如果当前文件夹位于C:,则路径指向C:\editors\tinymce
。如果希望此路径指向另一个驱动器,则必须指定它。为什么D:
而不是例如E:`或Z:`?但是如果我使用它,我会得到这个Path@SamDaniel这是正确的结果。这就是相对路径——相对于某个文件夹。如果未指定任何文件夹,则该文件夹为当前文件夹。如果希望它指向不同的驱动器,则需要指定所需的驱动器。操作系统不会搜索所有连接的驱动器来查找匹配项,但是如果我使用它,我会得到这个Path@SamDaniel这是正确的结果。这就是相对路径——相对于某个文件夹。如果未指定任何文件夹,则该文件夹为当前文件夹。如果希望它指向不同的驱动器,则需要指定所需的驱动器。操作系统不会搜索所有连接的驱动器以查找匹配项如果我使用此选项,则会指出我的C驱动器,但实际文件位于D驱动器字符串partialPath=“\\editors\\tinymce”;var output=Server.MapPath(partialPath);如果使用此选项,我的C驱动器将被指出,但实际文件位于D驱动器字符串partialPath=“\\editors\\tinymce”中;var output=Server.MapPath(partialPath);