Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何将所有输入文件复制到ICR创建的临时目录中_C#_Html - Fatal编程技术网

C# 如何将所有输入文件复制到ICR创建的临时目录中

C# 如何将所有输入文件复制到ICR创建的临时目录中,c#,html,C#,Html,如何使我创建的临时目录中的所有输入文件可用。只有最后一个文件存在。。我想要从文件的开始到结束的所有文件。 希望有人能在这里找到我的问题 下面是我的代码 var partText = Global.PartText; Global.PartText = string.Empty; Global.TmpFileCount = 0; var tempfile = Global.TempContent; Gl

如何使我创建的临时目录中的所有输入文件可用。只有最后一个文件存在。。我想要从文件的开始到结束的所有文件。 希望有人能在这里找到我的问题

下面是我的代码

var partText = Global.PartText;
            Global.PartText = string.Empty;
            Global.TmpFileCount = 0;
            var tempfile = Global.TempContent;
            Global.TempContent = string.Empty;
            var temp = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Temp");
            if (Directory.Exists(temp))
            {
                Directory.Delete(temp, true);
            }
            Directory.CreateDirectory(temp);
            var content = File.ReadAllText(inputfile);
            tempfile = Path.Combine(temp, string.Concat(Path.GetFileNameWithoutExtension(inputfile), ".html"));
            File.WriteAllText(tempfile, content);
            var text = File.ReadAllText(tempfile);
            text = text.Replace("&", "&");
            File.WriteAllText(tempfile, text);
            Global.TmpFileCount++;
            if (tempfile.Contains("<h1"))
            {
                _chapterName = inputXDoc.XPathSelectElement("//h1").Value;
            }
            else if (tempfile.Contains("<h2"))
            {
                _chapterName = inputXDoc.XPathSelectElement("//h2").Value;
            }
            else if (tempfile.Contains("<h3"))
            {
                _chapterName = inputXDoc.XPathSelectElement("//h3").Value;
            }
            else if (tempfile.Contains("<h4"))
            {
                _chapterName = inputXDoc.XPathSelectElement("//h4").Value;
            }
            //Directory.Delete(temp, true);
            //var source = inputXDoc.Descendants(GetNamespace(ref namespace2, "").GetName("body"));
            //if (source.Descendants(GetNamespace(ref namespace2, "").GetName("div")).Any())
            //{
            //  var introduced5 = inputXDoc.Descendants(GetNamespace(ref namespace2, "").GetName("body"));
            //  if (introduced5.Descendants(GetNamespace(ref namespace2, "").GetName("div")).First().Attributes("id").Any())
            //  {
            //      var introduced6 = inputXDoc.Descendants(GetNamespace(ref namespace2, "").GetName("body"));
            //      _chapterName = introduced6.Descendants(GetNamespace(ref namespace2, "").GetName("div")).First().Attributes("id").First().Value;
            //  }
            //}
            if (Regex.IsMatch(ipName, "cover", RegexOptions.IgnoreCase))
            {
                return "cover";
            }
            if (Regex.IsMatch(ipName, "bibliography", RegexOptions.IgnoreCase))
            {
                return "bibliography";
            }
            if (Regex.IsMatch(ipName, "foreword", RegexOptions.IgnoreCase))
            {
                return "foreword";
            }
            if (Regex.IsMatch(ipName, "toc", RegexOptions.IgnoreCase))
            {
                return "toc";
            }
            if (Regex.IsMatch(ipName, "cop(yright)?", RegexOptions.IgnoreCase))
            {
                return "copyright-page";
            }
            if (Regex.IsMatch(ipName, "halftitlepage", RegexOptions.IgnoreCase))
            {
                return "title-page";
            }
            if (Regex.IsMatch(ipName, "titlepage", RegexOptions.IgnoreCase))
            {
                return "title-page";
            }
            if (Regex.IsMatch(ipName, "ded(ication)?", RegexOptions.IgnoreCase))
            {
                return "dedication";
            }
            if (Regex.IsMatch(ipName, "part", RegexOptions.IgnoreCase))
            {
                Global.PartText = _chapterName;
                return "text";
            }
            Global.PartText = partText;
            const string str = "text";
            Global.FileCount++;
var partText=Global.partText;
Global.PartText=string.Empty;
Global.TmpFileCount=0;
var tempfile=Global.TempContent;
Global.TempContent=string.Empty;
var temp=Path.Combine(AppDomain.CurrentDomain.BaseDirectory,“temp”);
如果(目录存在(临时))
{
删除目录(temp,true);
}
创建目录(temp);
var content=File.ReadAllText(inputfile);
tempfile=Path.Combine(temp,string.Concat(Path.getfilenamwithoutextension(inputfile),“.html”);
writealText(临时文件,内容);
var text=File.ReadAllText(tempfile);
text=文本。替换(“&”、“&;”;
writealText(tempfile,text);
Global.TmpFileCount++;

如果(tempfile.Contains)(您每次都在删除目录。请更改此选项:

        if (Directory.Exists(temp))
        {
            Directory.Delete(temp, true);
        }
        Directory.CreateDirectory(temp);
为此:

        if (!Directory.Exists(temp))
        {
            Directory.CreateDirectory(temp);
        }

你应该真正开始使用面前可用的工具,即
调试器
。不要只
编码然后去
,看起来你正在尝试将目录中的所有html文件合并到一个目录中,但你应该真正查看你的代码并理解它在做什么。发布代码时,你也不确定不管你在做什么,如果你添加评论会有很大帮助。