本文整理汇总了C#中System.IO.TempFile.MoveTo方法的典型用法代码示例。如果您正苦于以下问题:C# TempFile.MoveTo方法的具体用法?C# TempFile.MoveTo怎么用?C# TempFile.MoveTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.TempFile
的用法示例。
在下文中一共展示了TempFile.MoveTo方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestEnvironment
public TestEnvironment(string rfctag, string rfctag2)
{
_folder = new TemporaryFolder("WritingSystemsInoptionListFileHelper");
var pathtoOptionsListFile1 = Path.Combine(_folder.Path, "test1.xml");
_optionListFile = new IO.TempFile(String.Format(_optionListFileContent, rfctag, rfctag2));
_optionListFile.MoveTo(pathtoOptionsListFile1);
}
示例2: TestEnvironment
public TestEnvironment(string liftFileContent)
{
_folder = new TemporaryFolder("WritingSystemsInLiftFileHelper");
var pathtoLiftFile1 = Path.Combine(_folder.Path, "test1.lift");
_liftFile1 = new IO.TempFile(liftFileContent);
_liftFile1.MoveTo(pathtoLiftFile1);
Helper = new WritingSystemsInLiftFileHelper(WritingSystems, _liftFile1.Path);
}
示例3: DeleteWritingSystemId
public void DeleteWritingSystemId(string id)
{
var fileToBeWrittenTo = new IO.TempFile();
var reader = XmlReader.Create(_liftFilePath, Xml.CanonicalXmlSettings.CreateXmlReaderSettings());
var writer = XmlWriter.Create(fileToBeWrittenTo.Path, Xml.CanonicalXmlSettings.CreateXmlWriterSettings());
//System.Diagnostics.Process.Start(fileToBeWrittenTo.Path);
try
{
bool readerMovedByXmlDocument = false;
while (readerMovedByXmlDocument || reader.Read())
{
readerMovedByXmlDocument = false;
var xmldoc = new XmlDocument();
if (reader.NodeType == XmlNodeType.Element && reader.Name == "entry")
{
var entryFragment = xmldoc.ReadNode(reader);
readerMovedByXmlDocument = true;
var nodesWithLangId = entryFragment.SelectNodes(String.Format("//*[@lang='{0}']", id));
if (nodesWithLangId != null)
{
foreach (XmlNode node in nodesWithLangId)
{
var parent = node.SelectSingleNode("parent::*");
if (node.Name == "gloss")
{
parent.RemoveChild(node);
}
else
{
var siblingNodes =
node.SelectNodes("following-sibling::form | preceding-sibling::form");
if (siblingNodes.Count == 0)
{
var grandParent = parent.SelectSingleNode("parent::*");
grandParent.RemoveChild(parent);
}
else
{
parent.RemoveChild(node);
}
}
}
}
entryFragment.WriteTo(writer);
}
else
{
writer.WriteNodeShallow(reader);
}
//writer.Flush();
}
}
finally
{
reader.Close();
writer.Close();
}
File.Delete(_liftFilePath);
fileToBeWrittenTo.MoveTo(_liftFilePath);
}
示例4: ReplaceWritingSystemId
public void ReplaceWritingSystemId(string oldId, string newId)
{
var fileToBeWrittenTo = new IO.TempFile();
var reader = XmlReader.Create(_liftFilePath, Xml.CanonicalXmlSettings.CreateXmlReaderSettings());
var writer = XmlWriter.Create(fileToBeWrittenTo.Path, Xml.CanonicalXmlSettings.CreateXmlWriterSettings());
//System.Diagnostics.Process.Start(fileToBeWrittenTo.Path);
try
{
bool readerMovedByXmlDocument = false;
while (readerMovedByXmlDocument || reader.Read())
{
readerMovedByXmlDocument = false;
var xmldoc = new XmlDocument();
//We load up the header and entry nodes individually as XmlDocuments and replace the writing systems
//This is not as fast as pure reader writers, but as this is not a frequent operation, that is ok and
//it is MUCH easier to code than a statemachine using readers and writers only.
if (reader.NodeType == XmlNodeType.Element && reader.Name == "header")
{
var headerFragment = xmldoc.ReadNode(reader);
readerMovedByXmlDocument = true;
GetNodeWithWritingSystemIdsReplaced(oldId, newId, headerFragment);
headerFragment.WriteTo(writer);
}
if (reader.NodeType == XmlNodeType.Element && reader.Name == "entry")
{
var entryFragment = xmldoc.ReadNode(reader);
readerMovedByXmlDocument = true;
GetNodeWithWritingSystemIdsReplaced(oldId, newId, entryFragment);
entryFragment.WriteTo(writer);
}
else
{
writer.WriteNodeShallow(reader);
}
//writer.Flush();
}
}
finally
{
reader.Close();
writer.Close();
}
File.Delete(_liftFilePath);
fileToBeWrittenTo.MoveTo(_liftFilePath);
}