You need to normalize the path
string normalizedPath = @"\\?\" + fileName; using (XmlWriter writer = new XmlTextWriter(normalizedPath, Encoding.UTF8)) { }