读取XML文件虽然路径包含特殊字符,如Dot(“。”)? [英] Read the XML file While path contains Special Character like Dot(".") ?
问题描述
当我试图用路径读取xml时这样:C:\ Users \ DIARA.RZ \Desktop\rabih\MagazineBuilderBin [10-5-2014] \\\\Debug \\ Page / TOB.xml
文件夹名称DIARA.RZ创建问题,如何在路径中允许特殊字符如(。)。 />
我使用下面的函数生成Filename,其中FolderName是可验证的并且它包含文件名。
public static string GetFilePath()
{
var path = @ System.AppDomain.CurrentDomain.BaseDirectory +FlipBook_+ FolderName;
返回路径;
}
我在使用此路径访问XML文件时遇到错误。但是当我从文件夹名称中删除Dot(。)时,它可以正常工作。
When I am trying to read the xml with Path Is Like This: C:\Users\DIARA.RZ\Desktop\rabih\MagazineBuilderBin[10-5-2014]\bin\Debug\Page/TOB.xml
the folder name "DIARA.RZ" creating problem, how can i allow the special characters like(.) in the path.
I am generating Filename using below function where FolderName is veriable and its Contains the the name of file.
public static string GetFilePath()
{
var path = @System.AppDomain.CurrentDomain.BaseDirectory + "FlipBook_" + FolderName;
return path;
}
and I am getting error when I am using this path to access the XML file. but when i removing the Dot(.) from folder name it works fine.
推荐答案
C:\ Users \ DIARA.RZ \Desktop \rabih \\ \\MagazineBuilderBin [10-5-2014] \\\\Debug \ page /TOB.xml
为什么用'/'代替' \'最后?
除了使用这个
使用System.IO;
公共静态字符串GetFilePath()
{
var path = @ System.AppDomain.CurrentDomain.BaseDirectory +FlipBook_ + FolderName;
返回Path.GetFullPath(路径);
}
C:\Users\DIARA.RZ\Desktop\rabih\MagazineBuilderBin[10-5-2014]\bin\Debug\Page/TOB.xml
why using '/' in place of '\' at last?
besides use this
using System.IO;
public static string GetFilePath()
{
var path = @System.AppDomain.CurrentDomain.BaseDirectory + "FlipBook_" + FolderName;
return Path.GetFullPath(path);
}
这篇关于读取XML文件虽然路径包含特殊字符,如Dot(“。”)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!