>>>FileStream stream = null; >>>try >>>{ >>> stream = File.Create(saveName); >>> XmlSerializer xml = new XmlSerializer(record.GetType()); >>> xml.Serialize(stream, record); >>>} >>> >>>where "saveName" is equal to >>>"C:\\DevelopCSharp\\Pacifica.Tracker\\TrackerClient\\Database\\SpotQueue\\Spot_3-11-2009(15:49:59).xml" >>>or since I thought the Pacifica.Tracker with a period in it might be the problem >>>"C:\\DevelopCSharp\\TrackerClientTemp\\Database\SpotQueue\\Spot_3-11-2009(15:49:59).xml" >>>>>>None of this works. The file name with the time in parens was working for weeks, the only thing that changed was the app directory.
>>string saveName = @"C:\DevelopCSharp\TrackerClientTemp\Database\SpotQueue\Spot_3-11-2009(15:49:59).xml"; >>>>Then you don't have to mess with the double slash
>string saveName = this.FileQueueDataPath + @"\Spot_" + fileID + ".xml"; >FileStream stream = null; >try >{ > stream = File.Create(saveName); > // everthing else left out >} > >public string FileQueueDataPath >{ > get > { > if (_queueDataPath == "") > { > _queueDataPath = TrackerSettings.Instance.AppDirectory + TrackerSettings.Instance.QueueDirectory; > } > return _queueDataPath; > } >} > >Settings File contains: >public string AppDirectory = @"C:\DevelopCSharp\TrackerClientTemp"; >public string QueueDirectory = @"\Database\SpotQueue"; > >public string CreateFileID() >{ > DateTime now = DateTime.Now; > if (TrackerSettings.Instance.UseUtcFileId) > now = now.ToUniversalTime(); > > string fileID = now.Month.ToString() + "-" + now.Day.ToString() + "-" + now.Year.ToString() + "("; > fileID += now.Hour.ToString() + ":" + now.Minute.ToString() + ":" + now.Second.ToString() + ")"; > > return fileID; >} >>
string saveName = Path.Combine(this.FileQueueDataPath, string.Format("Spot_{0}.xml", fileID); FileStream stream = null; try { stream = File.Create(saveName); // everthing else left out } public string FileQueueDataPath { get { if (_queueDataPath == "") { _queueDataPath = Path.Combine(TrackerSettings.Instance.AppDirectory, TrackerSettings.Instance.QueueDirectory); } return _queueDataPath; } } Settings File contains: public string AppDirectory = @"C:\DevelopCSharp\TrackerClientTemp"; public string QueueDirectory = @"\Database\SpotQueue"; public string CreateFileID() { DateTime now = DateTime.Now; if (TrackerSettings.Instance.UseUtcFileId) now = now.ToUniversalTime(); string fileID = now.Month.ToString() + "-" + now.Day.ToString() + "-" + now.Year.ToString() + "("; fileID += now.Hour.ToString() + ":" + now.Minute.ToString() + ":" + now.Second.ToString() + ")"; return fileID; }You could also use File.Exist() to find out if the file exists