you need to normalize it
string normalizedPath = @"\\?\" + longFilePath; sing (XmlWriter writer = new XmlTextWriter(normalizedPath, Encoding.UTF8))