I am currently working on a web service that retrieves an XML message, archives it, and then processes it further. The archive folder is read from Web.config. Here's what the archive method looks like
private void Archive(System.Xml.XmlDocument xmlDocument)
{
try
{
string directory = System.Configuration.ConfigurationManager.AppSettings.Get("ArchivePath");
ParseMessage(xmlDocument);
directory = string.Format(@"{0}\{1}\{2}", directory, _senderService, DateTime.Now.ToString("MMMyyyy"));
System.IO.Directory.CreateDirectory(directory);
string Id = _messageID;
string senderService = _senderService;
xmlDocument.Save(directory + @"\" + DateTime.Now.ToString("yyyyMMdd_") + Id + "_" + System.Guid.NewGuid().ToString().Substring(0, 13) + ".xml");
}
The structure of the path I get is C: \ Program Files \ Subfolder \ Subfolder. In development environments, QA, UAT and PRD everything works fine. But on another computer, I now need to install the web service (unfortunately, I can’t debug it), the directory line is "C: Files". Just to make sure that I double-checked the .NET version on different machines (I thought maybe using @ before the line depended on the version); all machines use 2.0.50727.
Does anyone know this problem?
Thanks in advance!
EDIT: @ , , . , @( , ).
():
@ , @ "c:\folder\subfolder", , escape-, ? , , ?
( , Path.Combine, . , )