Silverlight アプリケーションのクライアントから呼び出す WCF サービスがあり、それに文字列のファイル名パラメーターと xml を含む文字列パラメーターを渡します。サービス メソッドでは、xml 文字列を含む XDocument インスタンスを作成し、それをサーバーの ClientBin フォルダー内のファイルに保存します。絶対パスを使用しており、現在相対パスに切り替えようとしていますが、正しく行う方法がわかりません。私のコードは次のようになります。
public void WriteXmlToServer(string filename,string xmlString)
{
//xml document to hold the information for the group that is registered
XDocument xDoc = new XDocument(XDocument.Parse(xmlString.ToString()));
XDocument DataInFile = new XDocument();
try
{
xDoc.Save(Path.Combine("..\\ClientBin\\", filename));
//the complete absolute path to the .xml file ->C:\Users\Me\Documents\Visual Studio 11\Projects\SL_xMonitor_Frontend_RefactorV1_Backup82212\SL_xMonitor_Frontend_RefactorV1.sln
}
catch (FileNotFoundException e)
{
Console.WriteLine(e.InnerException.ToString());
}
}
現在、次の例外メッセージが表示されています。
System.IO.DirectoryNotFoundException was unhandled by user code
HResult=-2147024893
Message=Could not find a part of the path 'C:\Program Files (x86)\Common Files\Microsoft Shared\DevServer\ClientBin\ServerGroups.xml'.
Silverlight アプリケーションでクライアント ビン内のファイルへの相対パスを使用する正しい方法を教えてください。